【问题标题】:how to close the hyperlink window?如何关闭超链接窗口?
【发布时间】:2011-06-05 17:12:37
【问题描述】:

我的应用程序有一个问题。我正在构建一个具有导航控制器的应用程序。当我选择特定行时,将加载其相关的 url。它工作正常。但是如何从这个视图返回到前一个视图?我试图在视图顶部放置一个导航栏,但它不可见。你能帮帮我吗.....

我在 do selectrowmethod 中放了如下代码

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //获取选中的国家 NSString *selectedCountry = [listOfItems objectAtIndex:indexPath.row];

    //NSString *url=@"";

    如果 (indexPath.row==0) {

    //url=@"http://www.osha.gov/dcsp/osp/stateprogs/alaska.html" ; //label.text=url; NSLog(@"======"); NSURL *url = [[NSURL alloc] initWithString:@"http://labor.state.ak.us/lss/oshhome.htm"]; [[UIApplication sharedApplication] openURL:url]; // self.label.text=@"url"; // NSLog(@"++++++:%@",self.label.text); //textView.text=@"url";

    }

    else if(indexPath.row==1) {

    NSURL *url = [[NSURL alloc] initWithString:@"http://www.ica.state.az.us/ADOSH/"]; [[UIApplication sharedApplication] openURL:url];

    //url=@"http://www.osha.gov/dcsp/osp/stateprogs/arizona.html"; } 否则 if(indexPath.row==2) {

    NSURL *url = [[NSURL alloc] initWithString:@"http://www.dir.ca.gov/occupational_safety.html"]; [[UIApplication sharedApplication] openURL:url];

    //url=@"http://www.osha.gov/dcsp/osp/stateprogs/arizona.html"; }

    else if(indexPath.row==3) {

    NSURL *url = [[NSURL alloc] initWithString:@"http://www.ctdol.state.ct.us/osha/osha.htm"]; [[UIApplication sharedApplication] openURL:url];

    //url=@"http://www.osha.gov/dcsp/osp/stateprogs/arizona.html"; } }

【问题讨论】:

  • 如果您的代码使用代码标签,会有更多人愿意帮助您。
  • 你想做什么? [[UIApplication sharedApplication] openURL:url];将打开 Safari 应用程序?我认为您需要阅读 UIApplicationDelegate 协议参考。
  • 先生,我想做的是,当我选择一行时,它的特定 url 应该被打开。这就是我在 didselectrow 方法中加载 url 的原因。我已经看到 UIApplicatonDelegate 协议参考。我发现, - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url......这个方法有用吗?我尝试在delegate中使用它。但没有用..请告诉我哪里出错了

标签: iphone ios4 ios-simulator


【解决方案1】:

您的代码将打开 Safari。你不能从那里回去。我建议您查看UIWebView

【讨论】:

  • 先生,我在选择行方法中编写了编码,我该如何使用 webview?我真的不知道先生,请帮助我。我看过 uiapplication 协议参考,- (BOOL)application:(UIApplication * )application handleOpenURL:(NSURL *)url......这个方法有用吗?我尝试在delegate中使用它。但没有用..
猜你喜欢
  • 2015-02-01
  • 2022-06-30
  • 2010-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-16
相关资源
最近更新 更多