大佬教程收集整理的这篇文章主要介绍了iphone – 如何使用滑动手势XCode交换视图,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我不想使用滚动视图,因为我有几十个视图控制器,我希望用户能够轻扫.
这是一个例子:
First View Controller.xib:
SwipeRight-转到第二个View Controller.xib
第二视图Controller.xib:
SwipeLeft-转到第一个View Controller.xib
SwipeRight-转到第三个View Controller.xib
等等
我之前没有使用UISwipe / Touch Gestures,但是我使用IBACtion方法使用带模态转换的按钮切换视图(见下文):
-(IBACtion)swapViews; { SecondViewController *second2 =[[SecondViewController alloc initWithNibName:@"SecondViewController" bundle:nil]; second2.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:second2 animated:YES]; [second2 release]; }
使用滑动来执行不同格式的类似方法吗?如果是这样,我该如何排序并格式化它.
谢谢
编辑 – 回答每个问题的评论
将它放在viewDidLoad中
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@SELEctor(swipeLeftDetected:)]; swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeRecognizer]; [swipeRecognizer release];
- (IBACtion)swipeLeftDetected:(UIGestureRecognizer *)sender { NC2ViewController *second2 =[[NC2ViewController alloc] initWithNibName:@"NC2ViewController" bundle:nil]; second2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:second2 animated:YES]; [second2 release]; }
然后确保导入要交换使用的otherViewController
#import "SecondViewController"
在主文件的顶部.希望这可以帮助.
结束编辑
有关如何使用它们的更多信息,请阅读“事件处理指南”的Gesture Recognizers部分.
以上是大佬教程为你收集整理的iphone – 如何使用滑动手势XCode交换视图全部内容,希望文章能够帮你解决iphone – 如何使用滑动手势XCode交换视图所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。