Uiviewcontroller 如何使用滑动手势加载第二个视图控制器?
我有一个基于选项卡的应用程序,我想使用滑动手势在视图控制器中导航。 我试过: 与此配套:Uiviewcontroller 如何使用滑动手势加载第二个视图控制器?,uiviewcontroller,uigesturerecognizer,Uiviewcontroller,Uigesturerecognizer,我有一个基于选项卡的应用程序,我想使用滑动手势在视图控制器中导航。 我试过: 与此配套: - (void)viewDidLoad; { UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftDetected:)]; swipeRecognizer.direction = UISwipeGes
- (void)viewDidLoad; {
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftDetected:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRecognizer];
}
但它在刷卡时崩溃了。有什么帮助吗?谢谢 您的代码在我的Xcode上运行良好。 仅更改:
UISecondViewController *second =[[UISecondViewController alloc] initWithNibName:@"UISecondViewController" bundle:nil];
致:
因为我没有UISecondViewController类。
只需验证您的项目中是否存在UISecondViewController.xib,否则它将崩溃。
但我不确定这是你的问题
UISecondViewController *second =[[UISecondViewController alloc] initWithNibName:@"UISecondViewController" bundle:nil];
SecondViewController *second =[[SecondViewController alloc] init];