第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在iOS中輕按以放大和雙擊以縮???

如何在iOS中輕按以放大和雙擊以縮小?

慕仙森 2019-12-03 10:47:11
我正在開發(fā)一個(gè)應(yīng)用程序,UIImages通過使用來顯示的畫廊UIScrollView,我的問題是,如何點(diǎn)按zoom并雙擊以zoom退出,使用處理時(shí)它是如何工作的UIScrollView。
查看完整描述

2 回答

?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

您需要實(shí)現(xiàn)UITapGestureRecognizer -文檔在這里 -在你的viewController


- (void)viewDidLoad

{

    [super viewDidLoad];       


    // what object is going to handle the gesture when it gets recognised ?

    // the argument for tap is the gesture that caused this message to be sent

    UITapGestureRecognizer *tapOnce = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOnce:)];

    UITapGestureRecognizer *tapTwice = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTwice:)];


    // set number of taps required

    tapOnce.numberOfTapsRequired = 1;

    tapTwice.numberOfTapsRequired = 2;


    // stops tapOnce from overriding tapTwice

    [tapOnce requireGestureRecognizerToFail:tapTwice];


    // now add the gesture recogniser to a view 

    // this will be the view that recognises the gesture  

    [self.view addGestureRecognizer:tapOnce];

    [self.view addGestureRecognizer:tapTwice];


}

基本上,這段代碼是說,UITapGesture在self.view方法中注冊(cè)a時(shí),將調(diào)用tapOnce或tapTwice,self具體取決于它是單擊還是雙擊。因此,您需要將以下tap方法添加到您的UIViewController:


- (void)tapOnce:(UIGestureRecognizer *)gesture

{

    //on a single  tap, call zoomToRect in UIScrollView

    [self.myScrollView zoomToRect:rectToZoomInTo animated:NO];

}

- (void)tapTwice:(UIGestureRecognizer *)gesture

{

    //on a double tap, call zoomToRect in UIScrollView

    [self.myScrollView zoomToRect:rectToZoomOutTo animated:NO];

}

希望能有所幫助


查看完整回答
反對(duì) 回復(fù) 2019-12-03
?
慕斯王

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊

Swift 3.0版本,雙擊可放大兩次。


@IBOutlet weak var scrollView: UIScrollView!

@IBOutlet weak var imageView: UIImageView!

某個(gè)地方(通常在viewDidLoad中):


let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(onDoubleTap(gestureRecognizer:)))

tapRecognizer.numberOfTapsRequired = 2

scrollView.addGestureRecognizer(tapRecognizer)

處理程序:


func onDoubleTap(gestureRecognizer: UITapGestureRecognizer) {

    let scale = min(scrollView.zoomScale * 2, scrollView.maximumZoomScale)


    if scale != scrollView.zoomScale {

        let point = gestureRecognizer.location(in: imageView)


        let scrollSize = scrollView.frame.size

        let size = CGSize(width: scrollSize.width / scale,

                          height: scrollSize.height / scale)

        let origin = CGPoint(x: point.x - size.width / 2,

                             y: point.y - size.height / 2)

        scrollView.zoom(to:CGRect(origin: origin, size: size), animated: true)

        print(CGRect(origin: origin, size: size))

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-12-03
  • 2 回答
  • 0 關(guān)注
  • 736 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)