viewdidload

viewDidLoad getting called twice on rootViewController at launch

扶醉桌前 提交于 2019-11-26 11:08:29
问题 Anyone know why this root View Controller\'s viewDidLoad is being called twice at launch? It\'s driving me nuts! here\'s the stack trace from first time through viewDidLoad : #0 0x0000276a in -[RootViewController viewDidLoad] at RootViewController.m:71 #1 0x3097548f in -[UIViewController view] #2 0x00002734 in -[RootViewController initWithCoder:] at RootViewController.m:39 #3 0x30ab5ce4 in -[UIClassSwapper initWithCoder:] #4 0x30514636 in _decodeObjectBinary #5 0x30514035 in _decodeObject #6

UIView - How to get notified when the view is loaded?

依然范特西╮ 提交于 2019-11-26 10:07:01
问题 Is there anything similar to the viewDidLoad of UIViewController for a UIView ??? I need to be notified as soon as a UIView has loaded (Subclass of UIView ), and perform some actions. 回答1: Depending on what kind of actions you need to perform, there are several techniques: -(id)initWithFrame:(CGRect)frame - UIView's designated initializer; always sent to a UIView to initialize it, unless the view is loaded from a nib; -(id)initWithCoder:(NSCoder *)coder - always sent to initialize a UIView

Why am I having to manually set my view's frame in viewDidLoad?

瘦欲@ 提交于 2019-11-26 03:33:28
问题 I have a pretty basic setup with a UINavigationController inside a UITabBarController. I\'m wanting to programmatically layout the view of the rootViewController of that navcontroller, but when I look at self.view.frame inside viewDidLoad, I get this (in landscape , for example): 1. view frame: {{20, 0}, {748, 1024}} // looks like an odd portrait mode Then I autorotate to Portrait, and I get this: 2. view frame: {{0, 0}, {768, 911}} Then when I go back to Landscape, the frame is now this: 3.

UIViewController viewDidLoad vs. viewWillAppear: What is the proper division of labor?

蓝咒 提交于 2019-11-26 03:02:22
问题 I have always been a bit unclear on the type of tasks that should be assigned to viewDidLoad vs. viewWillAppear : in a UIViewController subclass. e.g. I am doing an app where I have a UIViewController subclass hitting a server, getting data, feeding it to a view and then displaying that view. What are the pros and cons of doing this in viewDidLoad vs. viewWillAppear ? 回答1: viewDidLoad is things you have to do once. viewWillAppear gets called every time the view appears. You should do things