iPad用のアプリを書いています。このアプリでは、すべての画面のナビゲーションバーにある[共有]ボタンを使用する必要があります。ホームクラスに[共有]ボタンを適用しました。私は、ナビゲーションバー上のボタンを適用するには、次のコードを書いた:UIActionSheetが呼び出されるとアプリケーションがクラッシュする
CGRect frame5 = CGRectMake(835.0, 0.0, 40.0, 40.0);
UIImage *buttonImage5 = [UIImage imageNamed:@"ShareIcon.png"];
UIButton *ShareButton = [UIButton buttonWithType:UIButtonTypeCustom];
ShareButton.frame = frame5;
[ShareButton setBackgroundImage:buttonImage5 forState:UIControlStateNormal];
ShareButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
ShareButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[ShareButton addTarget:self action:@selector(actionSheet) forControlEvents:UIControlEventTouchUpInside];
[ShareButton setBackgroundColor:[UIColor clearColor]];
[self.navigationController.navigationBar addSubview:ShareButton];
共有ボタンは、電子メールや画面を印刷するために使用されます。この目的のために、私はUIActionSheetを使用しました。この方法は、共有ボタンに適用され
-(void)actionSheet:(id)sender
{
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Email", @"Print", nil];
[popup showFromRect:CGRectMake(720.0, 3.0, 40.0, 40.0) inView:[self view] animated:TRUE];
[popup showFromBarButtonItem:(UIBarButtonItem *)sender animated:TRUE];
[popup release];
}
:私はUIActionSheetを適用するには、次の方法を書きました。私のアプリケーションをビルドして実行すると、エラーや警告は表示されません。つまり、ビルドは成功しています。しかし、私は、共有ボタンにアプリケーションのクラッシュをクリックして、それがデバッガのコンソールウィンドウに次を示す場合:なぜこれが起こっている
[Session started at 2011-10-21 21:26:58 +0530.]
2011-10-21 21:27:03.895 NewBostonEndoscopy[1351:207] -[Home actsht]: unrecognized selector sent to instance 0x6227010
2011-10-21 21:27:03.898 NewBostonEndoscopy[1351:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Home actsht]: unrecognized selector sent to instance 0x6227010'
私は得ていないのです。どんな推測? ご協力いただければ幸いです。 おかげに関して Prateekあなたは二回、ポップアップを見せている
「actsht」メソッドとは何ですか?このメソッドが呼び出される場所。明らかに、このセレクタを間違ったオブジェクトで呼び出そうとしています。 – kovpas
おかげKovpasは、私が.... –