Add a UIView using Interface Builder, remove, then add to another view
Due to problems having a split view within a tab view, I have created my application as a tab view and am trying to simulate split view functionality within one of my tabs.
I have created the left hand side panel of the split view in the Interface Builder in the landscape orientation. When the user 开发者_高级运维changes to portrait, I want to programmatically remove the left hand side panel from the view and add it to a popover panel to be launched from a toolbar button. Then vice versa, of course.
I thought I knew how to do this, but it's not working. I've created a UIViewController which does this:
- (void)viewDidLoad
{
[super viewDidLoad];
[playMakerToolsView removeFromSuperview];
[self.view addSubview:playMakerToolsView];
}
...where playMakerToolsView
is the reference to the UIView added from the Interface Builder.
But I'm finding when I launch this popover, it doesn't seem to show correctly. The popover is blank.
I'm relatively new to iOS development so I'm probably missing something obvious. If you could point me in the right direction that'd be great.
Why you are removing left side view? you can just hide it and set frames for main view.
Are you retaining playMakerToolsView anywhere? If not, when you remove it from the superview it is potentially up for dealloc'ing.
精彩评论