私はUIButtonにアクションを追加しようとしているが、例外得続ける午前にIBActionを追加しようとすると:キャッチされない例外により「NSInvalidArgumentException」にiPhone - プログラム的にUIButton
アプリを終了し、理由:「[UIImageView addTarget:アクションは:forControlEventsは:]:
- (void)viewDidLoad { [super viewDidLoad]; UIImage *myIcon = [UIImage imageNamed:@"Icon_Profile"]; self.profileButton = (UIButton*)[[UIImageView alloc] initWithImage:myIcon]; [self.profileButton addTarget:self action:@selector(profileButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *buttonItem = [[[UIBarButtonItem alloc] initWithCustomView:profileButton] autorelease]; NSArray *toolbarItems = [[NSArray alloc] initWithObjects:buttonItem, nil]; [self setToolbarItems:toolbarItems animated:NO]; //[toolbarItems release]; //[profileButton release]; }
そしてI H:未認識セレクタはインスタンス0x595fba0' に
を送信ここに私のコードであります同じビューコントローラでは、この方法をaveの:
-(void)profileButtonPressed:(id)sender{
}
とヘッダに私は
-(IBAction)profileButtonPressed:(id)sender;
を持って起こっていただきました!私は知りません。任意の助けに感謝:)
パーフェクト。みんな助けてくれてありがとう。 – shaw2thefloor