
我不想使用滚动视图,因为我有几十个视图控制器,我希望用户能够轻扫.
这是一个例子:
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"
在主文件的顶部.希望这可以帮助.
结束编辑
解决方法 这听起来像是使用 UIGestureRecognizer或更具体地说 UISwipeGestureRecognizer的完美时间.有关如何使用它们的更多信息,请阅读“事件处理指南”的Gesture Recognizers部分.
总结以上是内存溢出为你收集整理的iphone – 如何使用滑动手势XCode交换视图全部内容,希望文章能够帮你解决iphone – 如何使用滑动手势XCode交换视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)