开发者

Open web browser on launch of App

开发者 https://www.devze.com 2023-04-10 22:19 出处:网络
I need to know how to have an iphone app do nothing but open the web browser as soon as it starts.I know the code needed to open a broswer.. its

I need to know how to have an iphone app do nothing but open the web browser as soon as it starts. I know the code needed to open a broswer.. its

    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    [[UIApplication sharedApplication] openURL:url];

My problem is I don't know where to put this code. Ive tried putting it in main.m but it either errors or do开发者_如何转开发es nothing. I'd like to avoid needing to use a button. I'd prefer it be automatic as soon as the app is launched. I also need to image this to a HDMI TV and once again, I know the code for this.. I just don't know where it should be put, as I also want it to begin as soon as the app is started.

Thanks.


If you plan to submit this app to the App Store I've got bad news for you, Apple will reject your app if all it does is open a website.

But back to your question place the code in app delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    [[UIApplication sharedApplication] openURL:url];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号