0
从我的Objective C iPhone应用程序中,我希望用户点击“注册”帐户按钮,然后在我的网站上打开注册页面。 iPhone上的代码是为了响应用户操作而打开网站的代码?在Iphone上,我该如何实现一个可以打开网站的按钮?
从我的Objective C iPhone应用程序中,我希望用户点击“注册”帐户按钮,然后在我的网站上打开注册页面。 iPhone上的代码是为了响应用户操作而打开网站的代码?在Iphone上,我该如何实现一个可以打开网站的按钮?
创建一个UIButton和行动分配给这样的方法:
- (IBAction)register:(id)sender {
//you'll want to subclass UIViewController
SomeViewController *webViewController = [[SomeViewController alloc]init];
[self presentModalViewController:webViewController animated:YES];
[webViewController release];
}
你SomeViewController将有一个网页流量是负载的您的注册页面。然后在你的“SomeViewController”的viewDidLoad中,做这样的事情:
- (void)viewDidLoad
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mysite.com/register"]];
//this is a webview that you either created in -loadView or IB
[self.webView loadRequest:request];
}
我还发现了一个更直接的方式来加载网站:UIApplication的*应用= [UIApplication的sharedApplication] [app openURL:[[NSURL alloc] initWithString:@“http://maps.google.com/maps?g=London”]]; – MikeN 2010-03-23 15:51:51
这种方式的作品,但它使你的用户离开你的应用程序。我不了解你,但是我讨厌它,当一个应用程序退出某些事情时,它可以做到为什么还在运行。他们可能会认为注册您的应用程序太麻烦了。在WebView中运行它是很好的UX。 – christo16 2010-03-23 15:56:06