ビューロードでは、2つのUILabelがあり、両方に同じtapGestureを追加しました。特定のラベルをタップすると、その機能を実行する必要がありますが、実行できませんか?
-(void)viewDidLoad{
lblEditProfile.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClicked:)];
[tapGestureRecognizer setNumberOfTapsRequired:1];
[lblEditProfile addGestureRecognizer:tapGestureRecognizer];
[tapGestureRecognizer release];
lblViewDetails.userInteractionEnabled = YES;
tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClicked:)];
[tapGestureRecognizer setNumberOfTapsRequired:1];
[lblViewDetails addGestureRecognizer:tapGestureRecognizer];
[tapGestureRecognizer release];
}
-(IBAction)labelClicked:(UITapGestureRecognizer*)tapGestureRecognizer
{
currentLabel = (UILabel *)tapGestureRecognizer.view;
NSLog(@"tap %@",tapGestureRecognizer.view);
if(currentLabel.text==@"Edit Profile")
{
UserProfile *userProfile = [[UserProfile alloc] initWithNibName:@"UserProfile" bundle:nil];
userProfile.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:userProfile animated:YES];
[userProfile release];
}
else
{
ViewDetails *viewDetails = [[ViewDetails alloc] initWithNibName:@"UserAppointments" bundle:nil];
viewDetails.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController: viewDetails animated:YES];
[viewDetails release];
}
}
しかし、EditProfileラベルをクリックすると、elseブロックになります。
クリックされたラベルを認識し、それに応じて必要なアクションを実行するにはどうすればよいですか?