【问题标题】:Sliding View From the Left从左侧滑动视图
【发布时间】:2011-11-21 22:49:49
【问题描述】:
【问题讨论】:
标签:
iphone
objective-c
ios
xcode
xcode4
【解决方案1】:
- 创建两个视图。视图 A 和视图 B
- ViewA 是加载的视图。
- 将 ViewB 添加到 ViewA,ViewB 不在屏幕上,因此用户看不到它。
- 在 ViewA 的 ViewDidLoad 中添加 UISwipeGestureRecognizer,以便您可以收到滑动手势的通知。
- 如果发生滑动,则使用 UITransition 将 ViewB 移动到视图中。
在 viewDidLoad 中捕捉滑动手势
UITapGestureRecognizer *swipe = [[UISwipeGestureRecognizerDirectionRight alloc] initWithTarget:self action:@selector(swipeDetected)];
[viewA addGestureRecognizer:swipe];
[swipe release];
-(void)swipeDetected {
//transition viewB into view of user
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0];
[UIView setAnimationDuration:0.75];
CGRect rect5 = CGRectMake(0, 0, 320, 480);
viewB.frame = rect5;
[UIView commitAnimations];
}
【解决方案2】:
您所指的是UIGestureRecognizer,尤其是方向为UISwipeGestureRecognizerDirectionLeft 的UISwipeGestureRecognizer。
您可以找到相关的Apple reference here。如果您使用这样的苹果,手势识别器非常简单。如果您需要有关具体细节的帮助,请发帖,我可以为您输入一个快速示例。
【解决方案3】:
Peter Boctor 写了一篇非常好的教程,介绍了在 UITableViewCell 上实现滑动(如 twitter/tweetie,以及您描述的应用程序)here。