有一个变量agencyWebsite
和一个标签,应该在点击下面方法的时候打开一个网站。
- (void)website1LblTapped {
NSURL *url = [NSURL URLWithString:self.agencyWebsite];
[[UIApplication sharedApplication] openURL:url];
}
在编译器的警报:
Incompatible pointer types sending UILabel* to parameter of type NSString*
再点击网站应用就会崩溃。不知道应该怎么解决?请高手指点一下,谢谢。
下面是设置label点击的代码:
UITapGestureRecognizer* website1LblGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(website1LblTapped)];
// if labelView is not set userInteractionEnabled, you must do so
[self.agencyWebsite setUserInteractionEnabled:YES];
[self.agencyWebsite addGestureRecognizer:website1LblGesture];
运行代码:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", self.agencyWebsite.text]];