IOS代碼筆記之左右滑動效果
更新時間:2016年07月06日 09:44:05 作者:情深雨蒙
這篇文章主要為大家詳細(xì)介紹了IOS代碼筆記之左右滑動效果的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了ios實現(xiàn)左右滑動操作代碼,供大家參考,具體內(nèi)容如下
一、效果圖
二、代碼
RootViewController.m
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title=@"可以向左(右)滑動"; //向右滑動 UISwipeGestureRecognizer *recognizerLeft; recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromLeft:)]; [recognizerLeft setDirection:(UISwipeGestureRecognizerDirectionLeft)]; [self.view addGestureRecognizer:recognizerLeft]; //向左滑動 UISwipeGestureRecognizer *recognizerRight; recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromRight:)]; [recognizerRight setDirection:(UISwipeGestureRecognizerDirectionRight)]; [self.view addGestureRecognizer:recognizerRight]; } #pragma -mark -手勢滑動 //向左滑動 -(void)handleSwipeFromLeft:(UISwipeGestureRecognizer *)recognizer { NSLog(@"-------進(jìn)入向左手勢滑動姿勢-------------"); if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"進(jìn)入向左手勢滑動姿勢" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil]; [alert show]; } } //向右滑動 -(void)handleSwipeFromRight:(UISwipeGestureRecognizer *)recognizer { NSLog(@"-------進(jìn)入向右手勢滑動姿勢-------------"); if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"進(jìn)入向右手勢滑動姿勢" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil]; [alert show]; } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS多線程應(yīng)用開發(fā)中使用NSOperation類的基本方法
這篇文章主要介紹了iOS多線程應(yīng)用開發(fā)中使用NSOperation類的基本方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-11-11IOS開發(fā)Swift?與?OC相互調(diào)用詳解
這篇文章主要為大家介紹了IOS開發(fā)Swift?與?OC相互調(diào)用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08詳解IOS11新特性之larget title的實現(xiàn)
本篇文章主要介紹了詳解IOS11新特性之larget title的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12iOS應(yīng)用中發(fā)送HTTP的get請求以及HTTP異步請求的方法
這篇文章主要介紹了iOS應(yīng)用中發(fā)送HTTP的get請求以及HTTP異步請求的方法,代碼為傳統(tǒng)的Objective-C語言,說明都簡單地融入于注釋之中,需要的朋友可以參考下2016-02-02iOS 中根據(jù)屏幕寬度自適應(yīng)分布按鈕的實例代碼
這篇文章主要介紹了iOS 中根據(jù)屏幕寬度自適應(yīng)分布按鈕的實例代碼,本文給大家分享兩種方式,代碼簡單易懂,需要的朋友可以參考下2016-11-11