I have an iPad app with split view controller.
I want to programmaticaly create and add subview to detailViewController in right bottom corner. To do that i try to get frame of detailView (app support autorotation, so that position not static)
i do next
in viewWillAppear for detailView i try to get frame and calculate position i need
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
CGRect btnRect = self.view.frame;
//it always return 1024*748 width and height
//even in landscape mode
//when as i think must return 1024-321=703*748 pxls
//where is my mistake? How i can get actual frame
//dimensions for detailViewController in landscape orientation
btnRect.origin.y = btnRect.size.height - 42;
btnRect.origin.x = btnRect.size.width - 42;
btnRect.size.height = 42;
btnRect.size.width = 42;
UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:someimage forState:UIControlStateNormal];
[[btn layer] setFrame:btnRect];
[self.view addSubview:btn];
}
But it always show me that detailView frame has 1024*748 dimensions. When in landscape mode i think it must be 703*748. What i need to do to get actual detailView frame?
You should want to change the frame of the view in the shouldAutorotateToInterfaceOrientation method.
An example:
(This one will adjust scrollView2 to fit its new orientation (88 pixels lower then the mainview))