我有我想從使用如何調用輕掃手勢的方法從另一種方法在Objective-C
[自performSelector另一種方法把這種姿態刷卡方法:@selector(handleSwipeGesture :) withObject:無afterDelay :10];
我想不通的語法放在@selector()
任何幫助表示讚賞。這裏是我的代碼:
- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender {
if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"swipe left");
TutorialMenuViewController *tutorialMenuViewController = [[TutorialMenuViewController alloc]
initWithNibName:@"TutorialMenuViewController" bundle:nil];
[self.navigationController pushViewController:tutorialMenuViewController animated:YES];
[tutorialMenuViewController release];
}
}
您必須爲相應的視圖註冊swipeGestureRecognizer。 – waheeda
謝謝。以下是什麼語法? [self performSelector:@selector(handleSwipeGesture :) withObject:nil afterDelay:10]; – hanumanDev
這是什麼問題?你正在調用它,雖然你不會進入if語句,因爲你正在傳遞一個'nil'對象。所以if語句看起來像這樣並且計算結果爲false [[無方向] == UISwipeGestureRecognizerDirectionLeft]' –