相关疑难解决方法(0)

如何判断UILabel是否被触摸?

我试图确定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];
.
.
.    
Run Code Online (Sandbox Code Playgroud)

然后我写回调.

 - (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];
  }
Run Code Online (Sandbox Code Playgroud)

现在的问题是,无论我在视图中触摸的位置是打开的.如何确定是否仅触摸了我的标签?

iphone events user-interface objective-c

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

events ×1

iphone ×1

objective-c ×1

user-interface ×1