几年后,我再次尝试使用 XCode 为 iOS 编写一些小应用程序。
我的 MainViewController 在 viewdidload 中包含这些行:
UIStoryboard* overviewStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *overviewController = [overviewStoryboard instantiateViewControllerWithIdentifier:@"Overview"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:overviewController];
...
[self addChildViewController:nav];
[self.view addSubview:nav.view];
[nav didMoveToParentViewController:self];
概览后面的控制器包含视图中的整个手势识别确实加载了:
财产
@property (nonatomic, strong) UISwipeGestureRecognizer *swipeGestureUpDown;
viewdidload:
self.tableView.dataSource = self;
self.tableView.delegate = self;
// gesture recognizer top
self.swipeGestureUpDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen)];
self.swipeGestureUpDown.numberOfTouchesRequired = 1;
self.swipeGestureUpDown.direction = (UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown);
[self.view addGestureRecognizer:self.swipeGestureUpDown];
并且 swipedScreen 只有一个 nslog:
- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture
{
NSLog(@"somewhere");
}
概览控制器包含一个带有自定义单元格的 tableView。主控制器将此概览控制器作为根控制器传递给导航,如果向上滑动,导航应该是 slideUp,如果向下滑动,则应该是 slideIn。如您在上面看到的,主控制器正在调用带有根控制器的导航控制器。
什么都没有发生,没有识别手势,并且在某些尝试中它会因此消息而崩溃
unrecognized selector sent to instance
有人现在该怎么办?