Tôi đang cố gắng xác định xem một nhãn UILabel có được chạm vào không và nếu có thì hãy làm gì đó. Tặng ..Tôi làm cách nào để xác định xem có chạm vào nhãn UIL không?
.
.
.
UILabel * site = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, 320, 30)];
site.text = [retriever.plistDict valueForKey:@"url"];
site.textAlignment =UITextAlignmentCenter;
site.backgroundColor = [UIColor clearColor];
site.textColor = [UIColor whiteColor];
site.userInteractionEnabled = YES;
[theBgView addSubview:site];
[site release];
.
.
.
Sau đó, tôi viết lại cuộc gọi.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
retriever = [PListRetriever sharedInstance];
CGPoint pt = [[touches anyObject] locationInView: self];
NSURL *target = [[NSURL alloc] initWithString:[retriever.plistDict valueForKey:@"url"]];
[[UIApplication sharedApplication] openURL:target];
}
Vấn đề là ngay bây giờ, bất kể tôi chạm vào Url chế độ xem đang được mở. Làm cách nào để xác định xem chỉ có nhãn của tôi đã được chạm vào?
Tại sao bạn không thay thế nhãn bằng một nút? – zonble