我有一个变量agencyWebsite
和一个标签,使用此方法单击时应该打开网站:
- (void)website1LblTapped {
NSURL *url = [NSURL URLWithString:self.agencyWebsite];
[[UIApplication sharedApplication] openURL:url];
}
我在编译器中收到警告说:
Incompatible pointer types sending UILabel* to parameter of type NSString*
单击链接时应用程序崩溃。有什么建议么?
编辑:这是我正在做的使标签可点击的操作
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]];