在程序启动时运行代码

编程入门 行业动态 更新时间:2024-10-27 00:27:45
本文介绍了在程序启动时运行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.google"]];

打开Safari并重定向到URL。

to open Safari and redirect to a URL.

在哪里可以放置此代码,以便程序在启动时运行此代码?

Where can I put this code in so as to let the program run this code at start-up?

一开始,我有 HelloWorldViewController文件.h, HelloWorldViewController.m和XCode 4生成的 HelloWorldViewController.xlb。

At the beginning, I have the file of "HelloWorldViewController.h", "HelloWorldViewController.m" and "HelloWorldViewController.xlb" that are generated by XCode 4.

已更新,我将以下代码添加到xxxx.m文件中,但不起作用,请帮助

Updated, I added the code as below to xxxx.m file, but not works, please help

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

推荐答案

好然后在statup上运行它。...

Ok, if you want to run it on statup then....

-(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

这在应用程序委托中。...不确定为什么您将要执行此操作,还是Apple是否会批准这样的应用程序...?

This is in the App Delegate....not sure why you would want to do this or whether Apple would even approve such an app...?

如果要显示Web内容,则可以使用UIWebview并加载该网址....

If you want to show web content then you can use a UIWebview and load the URL into that....

更多推荐

在程序启动时运行代码

本文发布于:2023-11-05 06:21:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560135.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   代码   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!