简体   繁体   English

iphone UIView - 在加载视图时收到通知?

[英]iphone UIView - Get notified when view has loaded?

I have a subclass of UIView, I want to be notified as soon as the view is loaded on the screen. 我有一个UIView的子类,我希望一旦视图加载到屏幕上就会收到通知。 Is there some kind of delegate method for a UIView. UIView是否有某种委托方法。


NOTE: I am not using a UIViewController 注意:我没有使用UIViewController

There is no delegate method but you can override, 没有委托方法但你可以覆盖,

- (void)didAddSubview:(UIView *)subview{
}

如果您不使用OpenGL,可以使用- (void)drawRect:(CGRect)rect

Set the class which opens your view as the delegate of the view, then on viewDidLoad (which runs as soon as the view is opened, even if it's not by a viewController per se) notify the delegate. 设置打开视图的类作为视图的委托,然后在viewDidLoad上(一旦打开视图就运行,即使它不是由viewController本身运行)通知委托。 That should work, I believe. 我相信这应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM