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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

有沒有辦法在iPhone上通過觸摸?

有沒有辦法在iPhone上通過觸摸?

慕慕森 2019-12-26 11:00:43
UIButton在主區(qū)域中點(diǎn)擊時,我使用幾個s來設(shè)置當(dāng)前動作。我還想允許用戶從按鈕直接拖動到主要區(qū)域并執(zhí)行相同的操作;本質(zhì)上,在觸摸UIButton時應(yīng)將touchesBegan和touchesMoved傳遞給主視圖,還應(yīng)發(fā)送按鈕按下動作?,F(xiàn)在,我可以更改控件了。拖動出口將調(diào)用內(nèi)部觸摸區(qū)域以設(shè)置控件,然后調(diào)用觸摸開始區(qū)域以開始主區(qū)域觸摸操作。但是,此時,touchesMoved和touchesEnded顯然沒有被調(diào)用,因為觸摸起源于UIButton。有沒有一種方法可以半忽略觸摸,以便將它們傳遞到主區(qū)域,還可以讓我先設(shè)置控件?
查看完整描述

3 回答

?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗 獲得超4個贊

在文檔中,查找“ 響應(yīng)者對象”和“響應(yīng)者鏈”


您可以通過轉(zhuǎn)發(fā)響應(yīng)者鏈上的修飾來“共享”對象之間的修飾。您的UIButton有一個接收UITouch事件的響應(yīng)器/控制器,我的猜測是,一旦它對返回的消息執(zhí)行了正確的解釋-觸摸已被處理和處置。


蘋果公司建議這樣的事情(當(dāng)然取決于觸摸的類型):


[self.nextResponder touchesBegan:touches withEvent:event];


而不是處理觸摸事件,而是將其傳遞出去。


子類UIButton:


MyButton.h


#import <Foundation/Foundation.h>


@interface MyButton : UIButton {


}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event ;


@end

我的按鈕


#import "MyButton.h"


@implementation MyButton


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {  

    printf("MyButton touch Began\n");

    [self.nextResponder touchesBegan:touches withEvent:event]; 

}

@end


查看完整回答
反對 回復(fù) 2019-12-26
?
喵喔喔

TA貢獻(xiàn)1735條經(jīng)驗 獲得超5個贊

我知道這個問題已經(jīng)有兩年了(并且已經(jīng)回答了),但是...


當(dāng)我自己嘗試時,觸摸被轉(zhuǎn)發(fā)了,但是按鈕不再像按鈕那樣表現(xiàn)。我也將修飾傳遞給“超級”,現(xiàn)在一切都很好。


因此,對于可能偶然發(fā)現(xiàn)此問題的初學(xué)者,代碼應(yīng)如下所示:


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {  

    [super touchesBegan:touches withEvent:event];

    [self.nextResponder touchesBegan:touches withEvent:event]; 

}


查看完整回答
反對 回復(fù) 2019-12-26
?
臨摹微笑

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

也無需繼承!只需將其放在實現(xiàn)的頂層即可,然后再進(jìn)行其他操作:


#pragma mark PassTouch


@interface UIButton (PassTouch)

@end


@implementation UIButton (PassTouch)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    [super touchesBegan:touches withEvent:event];

    [self.nextResponder touchesBegan:touches withEvent:event];

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

    [super touchesMoved:touches withEvent:event];

    [self.nextResponder touchesMoved:touches withEvent:event];

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

    [super touchesEnded:touches withEvent:event];

    [self.nextResponder touchesEnded:touches withEvent:event];

}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

{

    [super touchesCancelled:touches withEvent:event];

    [self.nextResponder touchesCancelled:touches withEvent:event];

}

@end


查看完整回答
反對 回復(fù) 2019-12-26
  • 3 回答
  • 0 關(guān)注
  • 750 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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