是在applicationDidFinishLaunching设置UIImageView图像的错误位置吗? [英] is applicationDidFinishLaunching the wrong place for setting an image for an UIImageView?

查看:40
本文介绍了是在applicationDidFinishLaunching设置UIImageView图像的错误位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了这一点:

applicationDidFinishLaunching(UIApplicationDelegate协议的委托方法)似乎已被调用,然后我的笔尖文件中的视图被完全加载.因此,我在iPhone模拟器中启动应用程序后,就整天试图更改UIImageView的图像,但没有任何反应.

applicationDidFinishLaunching (an delegate method of the UIApplicationDelegate Protocol) seems to be called BEFORE my views from the nib file are loaded completely. So I tried all the day to change an image of an UIImageView right after my app launched in the iPhone simulator, but nothing happened.

然后,我编写了一个小的操作方法,只需按一下按钮即可调用该方法.然后发生了:工作!

Then I wrote a little action method that I call with the press of a button. And then it happened: WORKS!

因此,applicationDidFinishLaunching委托方法并不是在应用程序真正准备就绪"后必须完成的工作的正确位置.我猜测还有更好的条件可以等待笔尖完全加载.但是哪里?还有什么?

So the applicationDidFinishLaunching delegate method isn't really the right place for stuff that has to be done after the app is really "ready". I gues there's something better that waits for the nib to be loaded completely. but where? and what?

推荐答案

我认为还有更好的条件可以等待笔尖完全加载.但是哪里?还有什么?

I gues there's something better that waits for the nib to be loaded completely. but where? and what?

对于特定于应用程序的事情,例如全局设置,首选项等, -appDidFinishLaunching 是正确的位置.

For application specific things like global settings, preferences, etc., -appDidFinishLaunching is the right place.

对于特定于UIView的事物,通常在UIVIewController子类中使用 -viewDidLoad 方法.几乎可以肯定,这是保证您可以装入nib文件,初始化IBOutlet并附加IBAction的唯一位置.

For UIView specific things, you typically use the -viewDidLoad method in a UIVIewController subclass. It is pretty much the only place you are guaranteed that the nib file is loaded, the IBOutlets are initialized and the IBActions are attached.

这与Mac OS X世界不同,在Mac OS X世界中, -awakeFromNib 是执行此操作的地方.

This is difference from the Mac OS X world, where -awakeFromNib was the place to do it.

这篇关于是在applicationDidFinishLaunching设置UIImageView图像的错误位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆