KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a navigation based application where I place my custom views in the navigation view. First, I wanna know how to get the "navigation view"'s frame so that I can place my custom view on it properly. Also, I sometimes hide navigation bar and want to make sure I get the frame info correctly. (not with [[UIScreen mainScreen] bounds] ) Second, in general, how do I access the superview's frame so that I can place a view accordingly? I tried the following with no success. -(void) loadView { [super loadView]; UIView* myView = [[UIView alloc] initWithFrame: CGRectZero]; self.view = myView; self.view.frame = self.view.superview.frame; [myView release]; } or setting the frame in layoutSubviews, but noticed layoutSubviews not getting called. I guess that's because I don't have any subviews in this particular view? Thank you -Edit- with given answers, i now know that i need to set the view.frame to superview's bounds. The problem is that i'm unable to access superview inside viewDidLoad. I can see that superview is correctly set in viewWillAppear but not in viewDidLoad. I found out that viewDidLoad gets called at various times, such as when pushed by pushViewController or accessing self.view I have the following code and viewDidLoad gets called from nil == controller.view.superview. if (nil == controller.view.superview) { CGRect frame = scrollView.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; controller.view.frame = frame; [scrollView addSubview:controller.view]; } Since I can't access superview from viewDidLoad, i can't layout the view as i previously did in viewDidLoad. This seems so inconvenient and unnecessarily complex. Any suggestion please?
Tags (comma-separated)
Save Edits
Cancel