中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

IOS端的搖一搖功能

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用

在 UIResponder中存在這么一套方法

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

這就是執(zhí)行搖一搖的方法。那么怎么用這些方法呢?

很簡(jiǎn)單,你只需要讓這個(gè)Controller本身支持搖動(dòng)

同時(shí)讓他成為第一相應(yīng)者:

- (void)viewDidLoad

{

    [superviewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    [[UIApplicationsharedApplication] setApplicationSupportsShakeToEdit:YES];

    [selfbecomeFirstResponder];

}

 

然后去實(shí)現(xiàn)那幾個(gè)方法就可以了

- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    //檢測(cè)到搖動(dòng)

}

 

- (void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    //搖動(dòng)取消

}

 

- (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    //搖動(dòng)結(jié)束

    if (event.subtype == UIEventSubtypeMotionShake) {

        //something happens

    }

}


標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:servlet實(shí)現(xiàn)文件上傳數(shù)據(jù)增刪該查

下一篇: android圓角矩形的實(shí)現(xiàn)