开发者

iPhone:Can't tap UILabel at specified frame using UITapGestureRecognizer

开发者 https://www.devze.com 2023-03-31 22:10 出处:网络
I am used UITapGestureRecognizer in my apps but I can\'t to tap on the UILabel only so please help to solve this problem and I want to redirect on next view controller click on eletter of UILabel so p

I am used UITapGestureRecognizer in my apps but I can't to tap on the UILabel only so please help to solve this problem and I want to redirect on next view controller click on e letter of UILabel so please help me .......

  self.label = [[UILabel alloc] initWithFrame:CGRectMake(45, 48, 94, 21)];
  self.label.backgroundColor = [UIColor clearColor];
  self.label.text = @"I like iPhone";

recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
  [self.label addGestureRecognizer:recognizer];
  [self.view addSubview:label];
   self.tapRecognizer = (UITapGestureRecognizer *)recognizer;
   recognizer.delegate = self;
   [recognizer release开发者_JS百科];    

Thanks in advance.


UILabel by default does not allow user interaction - you must explicitly enable it:

self.label.userInteractionEnabled = YES;


You have to enable user interaction for a label, it is disabled by default.

self.label.userInteractionEnabled = YES;
0

精彩评论

暂无评论...
验证码 换一张
取 消