Próbuję ustalić, czy dotknięto UILabel, a jeśli tak, to zrób coś. Podaj ..Jak ustalić, czy dotknięto UILabel?
.
.
.
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];
.
.
.
Następnie piszę wywołanie zwrotne.
- (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];
}
Problem jest teraz, bez względu na to, gdzie dotknę w widoku Wyświetl adres URL jest otwarty. Jak mogę ustalić, czy tylko moja etykieta została dotknięta?
Dlaczego po prostu nie zastąpisz swojej etykiety przyciskiem? – zonble