如何使用iOS应用中的按钮打开网页?

时间:2013-04-23 04:32:13

标签: ios objective-c

我试图通过将URL链接到按钮来从DashboardViewController打开网页。我有以下代码:

- (IBAction)facebook:(id)sender {
    [[DashboardViewController sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com"]];
}

然而,这会引发错误:

[DashboardViewController sharedApplication]: unrecognized selector sent to class 0xaba8
2013-04-22 23:23:35.264 LoginScreen[37692:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[DashboardViewController sharedApplication]: unrecognized selector sent to class 0xaba8'

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:2)

以下是您问题的解决方案 -

  1. press button to open web page from app

  2. Open web page inside iOS application

  3. 使用UIWebView,您可以将其添加为任何其他视图的子视图,然后使用您的URL调用loadRequest。