我正在尝试使用操作表通过链接打开 safari。变量设置正确并相应地显示链接,但由于某种原因,Safari 无法打开,我不知道为什么......
这是代码:
-(void)actionSheet {
sheet = [[UIActionSheet alloc] initWithTitle:@"Options"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Open in Safari", nil];
[sheet showInView:[UIApplication sharedApplication].keyWindow];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != -1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.url]];
}
}