【发布时间】:2015-08-09 01:41:01
【问题描述】:
我有一个 UIwebView,它在网页中有一些链接。我想要一个特定的链接来打开一个警报模式,如图像 #1 中所示
另外,如何使用下面的代码来制作这样的东西 - (IMAGE #1) http://screenshot.it.sftcdn.net/blog/it/2014/01/Block-user-03-Tasto-Block-378x568.png in objective-c
- (IBAction)showAlert:(id)sender
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Open In..."
message:@"Which app would you like to open?"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *mapsAction = [UIAlertAction actionWithTitle:@"Maps"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
if (![self openURLForString:@"maps://"]) {
NSLog(@"Couldn't Open Maps");
}
}];
UIAlertAction *youtubeAction = [UIAlertAction actionWithTitle:@"YouTube"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
if (![self openURLForString:@"http://www.youtube.com/watch?v=dQw4w9WgXcQ"]) {
NSLog(@"Couldn't Open YouTube");
}
}];
UIAlertAction *messagesAction = [UIAlertAction actionWithTitle:@"Messages"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
if (![self openURLForString:@"sms://"]) {
NSLog(@"Couldn't Open Messages");
}
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
[alertController addAction:mapsAction];
[alertController addAction:youtubeAction];
[alertController addAction:messagesAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
}
- (BOOL)openURLForString:(NSString *)urlString {
NSURL *url = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
return YES;
}
return NO;
}
“报告不当”是在第二个 UIwebView 中打开的链接,该链接在父 webview 上方打开,“共享”在 Safari 中打开。 (忽略“复制链接/网址”)
【问题讨论】:
-
不清楚您在问什么...您是在问如何执行模态视图控制器转换以呈现新的 Web 视图?
-
@stuart #1) 我希望 uiwebview 网页中的某个链接打开警报模式,如图像 #1 #2) 其中图像 #1 中的“报告不当”是一个链接在第二个 UIwebView 中打开,该 UIwebView 在父 webview 上打开,并且“共享”在 Safari 中打开。 (忽略“复制链接/URL”)
-
请在下面查看我的答案,如果它有效,请告诉我。谢谢。
标签: ios objective-c