我在我的代碼中有以下IBAction方法。如何以編程方式使用ID發件人調用IBAction方法?
-(IBAction)handleSingleTap:(id)sender
{
// need to recognize the called object from here (sender)
}
UIView *viewRow = [[UIView alloc] initWithFrame:CGRectMake(20, y, 270, 60)];
// Add action event to viewRow
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[singleFingerTap release];
//
UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(5,30, 100, 20)];
infoLabel.text = @"AAAANNNNVVVVVVGGGGGG";
//[viewRow addSubview:infoLabel];
viewRow.backgroundColor = [UIColor whiteColor];
// display the seperator line
UILabel *seperatorLablel = [[UILabel alloc] initWithFrame:CGRectMake(0,45, 270, 20)];
seperatorLablel.text = @" ___________________________";
[viewRow addSubview:seperatorLablel];
[scrollview addSubview:viewRow];
如何調用IBAction方法,同時允許它接收該方法的調用者對象?
感謝您的驚人提示。我設法得到該方法調用視圖的標籤。我在代碼中犯了一個錯誤,我已經將UITapGestureRecognizer分配給了self.view,而不是我想要分配的內容。 –