2017-06-19 5 views
0

こんにちは私はこのView Controllerに配列を持っていませんが、エラーが発生しています。このページを最初に訪問すると、最初は正常に動作しますが、最後のページで私はこのページにセグを使って戻ってきますView Controllerを再訪するとエラーが発生する

注: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 

これをのための私のログで終了します私のファイル

- (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"); 
} 
+0

ブレークポイントの例外を有効にしているので、クラッシュした場合、実際に(ほとんどの場合)クラッシュする行を指しますか? – Joshua

+0

@Joshuaどの例外?? uを得ることができません – Akshay

+0

例外のブレークポイントを追加できるオプションがブレークポイントのナビゲーションにあります。アプリケーションがクラッシュすると、どのファイルまたはどのラインにクラッシュするかを(ほとんどの場合、)指摘します。現行の問題を考えてみると、現在のコントローラに配列がないと言ったのでエラーを生成するものはどれか分かりません。 – Joshua

答えて

0

私のsegue接続は間違っていました。つまり、メニュービューコントローラに与えられていました。ビューコントローラを表示するために移動する必要がありました。[self.revealViewController panGestureRecogoniser];今それはうまく動作します!ご支援ありがとうございます!

関連する問題