0
嗨我沒有在這個視圖控制器中的數組,但我得到一個錯誤,當我先訪問此頁時它運行良好,但在我的最後一頁時,我想添加一個item回到本頁使用segue重溫一個視圖控制器給我錯誤
注意:1。當我第一次訪問這個頁面時,它流暢地沒有錯誤
我的目標是這是訂購食物和添加購物車以添加新項目的菜單頁我正在重新訪問此頁面,它給了我一個錯誤。 @
UIImageView *drinki = [[UIImageView alloc] init];
這是不必要的,所以我刪除它,然後
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onButtonTapped:)];
在這條線,我的應用程序終止
這是我的日誌中的錯誤
2017-06-19 09:01:58.156 Barebones[3337:314954] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason: '***
-[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
( 0 CoreFoundation 0x0000000111207b0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000110189141 objc_exception_throw + 48 2 CoreFoundation
0x000000011113c443 -[__NSArrayM insertObject:atIndex:] + 1603 3
UIKit 0x0000000111dd6736
-[UIView(UIViewGestures) addGestureRecognizer:] + 200 4 Barebones 0x000000010f827cb9 -[CategoryViewController viewDidLoad] + 985
這我的.m文件
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"Welcome";
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"background"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
//Left slidebutton
_leftbarbutton.target = self.revealViewController;
_leftbarbutton.action = @selector(revealToggle:);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
UIImageView *drinki = [[UIImageView alloc] init];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onButtonTapped:)];
_drinksi.userInteractionEnabled = YES;
[_drinksi addGestureRecognizer:tap];
UIImageView *foodi = [[UIImageView alloc] init];
UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onButtonTapped1:)];
_foodi.userInteractionEnabled = YES;
[_foodi addGestureRecognizer:tap1];
}
- (void)onButtonTapped1:(UITapGestureRecognizer *)gestureRecognizer {
[self performSegueWithIdentifier:@"p2" sender:self];
NSLog(@"it works");
}
- (void)onButtonTapped:(UITapGestureRecognizer *)gestureRecognizer {
//UIImageView *myImage = (UIImageView *)gestureRecognizer.view;
[self performSegueWithIdentifier:@"p2" sender:self];
NSLog(@"it works");
}
有你打開斷點例外,所以如果它不崩潰,它實際上將(大部分時間)指向崩潰行? – Joshua
@Joshua該例外??不能得到ü – Akshay
存在斷點導航,其中您可以添加例外斷點的選項。當應用程序崩潰時,它會指向你哪個文件或哪一行崩潰(大部分時間)。鑑於目前的問題,我們不知道哪個是生成錯誤,因爲你說當前控制器中沒有數組。 – Joshua