私の目標は、正しいものbutton.titleLabel.text
をビュー コントローラーの handleLongPress 関数に単純に送信することです。これは私の機能です:
- (IBAction)handleLongPress:(UILongPressGestureRecognizer *)sender {
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.0;
[self setUserIntendsToChangeUIsoTheUIisLockedUntilUserSelection:YES];
NSLog(@"sender? %@", sender);
if ([sender.view isKindOfClass:[UIButton class]]) {
self.myButton = (UIButton *)sender.view;
NSLog(@"!!!!! %@", self.myButton.titleLabel.text);
[self.view addSubview:self.scrollPickerView];
}
}
これは、ボタン「H」、「Cl」、「C」などの参照アウトレット コレクションを作成したストーリーボードです。
各ボタンは に応答しますが、別のボタンを押したとしてもUILongPressGesture
、記録されたメッセージNSLog(@"!!!!! %@", self.myButton.titleLabel.text);
は常に同じ UIButton "C" を参照します。私は何を間違えましたか?各ボタンのタイトルを handleLongPress 関数に送信するにはどうすればよいですか?