IPhone Objectvie C

Posted by Sea on Stack Overflow See other posts from Stack Overflow or by Sea
Published on 2010-03-29T15:59:32Z Indexed on 2010/03/29 16:03 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

I am trying to determine if a UILabel was touched and if so do something. Give ..

.
.
.
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];
.
.
.    

Then I write the callback.

 - (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];
  }

The problem is right now, no matter where I touch in the View the Url is being opened. How do I determine if only just my label was touched?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c