我是 iOS 新手。不确定是否有可能带来以下逻辑。
1. UITabBarController has three UIViewController.
2. While Swipping horizontally in the second UIViewController, i want to move
to the third UIViewController.
可能吗?。如果是这样,请建议如何实现相同的目标。
我是 iOS 新手。不确定是否有可能带来以下逻辑。
1. UITabBarController has three UIViewController.
2. While Swipping horizontally in the second UIViewController, i want to move
to the third UIViewController.
可能吗?。如果是这样,请建议如何实现相同的目标。
在第二个 ViewController 中,在 ViewDidLoad 中添加以下行
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoNextPage:)];
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
并添加方法
-(void)gotoNextPage:(id)sender {
[self.tabBarController setSelectedViewController:thirdViewController];
}
您可以使用我正在执行的 Touch Delegate Method 弹出到上一个视图
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint startPosoition = [touch previousLocationInView:self.view];
CGPoint endPosition = [touch locationInView:self.view];
if (endPosition.x - startPosoition.x > 20)
{
[self.navigationController popViewControllerAnimated:YES];
} else
{
}
}
是的,这是可以做到的。对于 1. 我假设您知道如何使用视图控制器设置基于标签栏的应用程序。对于 2. 在您的第二个视图控制器的视图和手势处理程序中实现滑动手势识别器:[self.yourTabBarController setSelectedIndex:2];
使用此代码;
UISwipeGestureRecognizer *swipeGestureNextPage = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(loadPreviousPageClicked)];
swipeGestureNextPage.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeGestureNextPage];
-(void)loadPreviousPageClicked
{
//use navigation controller here accordingly
}
而已。