I need to create a class that will present a UIVIew and has a some code to initialize it before it is ready to show. I need to know when the view is ready, I mean, I need something like viewDidLoad or viewWillAppear, but as it is a UIVIew it lacks these protocols.
I cannot implement it as a UIViewController as I don’t want to present it modal. It is really a rectangular view that needs to show on a screen side.
How do I declare this class? If the class is a UIView based I don’t have the methods I mentioned.
thanks
Any reason to not do that kind of stuff inside the
initWithFramemethod on aUIView? Also, you can do additional stuff onlayoutSubviews. A view controller hasviewDidLoadbecause the view is lazy loaded (from a nib or otherwise – it also has aloadView). It hasviewWillAppearandviewWillDisappearbecause it is managing the view (btw, even the view controller is managed by another view controller – these methods are called when you have the controller within a UINavigationController or UITabBarController or such classes which mange UIViewControllers. – the view itself is not really managing anything. All it knows about is how to draw itself. For that, you havelayoutSubViews,drawRect, etc.Doing some heavy stuff upon view’s load will definitely kill the UI performance. You probably need to implement another kind of design pattern that will asynchrounously assign data values to the instance of your custom view – when that is done, you call
layoutSubviewsorsetNeedsDisplayto update the view.