Loading UITabBarController from separate XIB into Window app on iPhone
I'm working on making an iPhone version of an Android app that I've written (so please bear with me). The application has a main view that basically displays a web view and some other controls that control the webview. I already have this part of the application working atop a UIWindow
.
The other part of the application is a 'profile' page that lets the user enter some profile information into a form. Due to the sheer number of options, I put together thing interface in a separate XIB using a UITabBarController
to hold everything together. I already have a delegate class for this part of the application so that I can operate on the form fields in the view(s).
When the app starts, it's supposed to display the 'profile' view to the user on first run and then later display the profile view when the user selects 'profile' in he app.
The problem I'm running into is that I cannot seem to find a good example (or have a good understanding of) how to cause the app to load the view and it's delegate. I开发者_Go百科f this were under Android, I would subclass Activity
and have it load the appropriate interface file.
Thus far I have a view controller:
@implementation customizeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
- (void)dealloc {
[super dealloc];
}
@end
And inside the application delegate header I have this setup for holding my 'profile' view:
UIView *CustomizeWindow;
Within didFinishLaunchingWithOptions
I have the following:
CustomizeWindow = [[customizeViewController alloc] initWithNibName:@"CustomizeWindow" bundle:[NSBundle mainBundle]];
[window makeKeyAndVisible];
...where CustomizeWindow
is the filename of the 'profile' view's file.
I have tried a few different ways of displaying this, such as adding it as a sub view to the window and presentModalViewController
with no success. I suspect there is a piece to this puzzle that I'm missing, so any help would be appreciated.
From everything I could read, there is no way to really do this. The solution was to throw everything out and make it simpler. In this case, a custom view controller using a UIScrollView to contain the other views and then load the other xib files programmatically.
Soemthing like:
NSArray *pages = [[NSBundle mainBundle] loadNibNamed:@"CustomizePage1" owner:self options:nil];
UIView *page1 = [pages objectAtIndex:0];
[page1 setBounds:CGRectMake(0, -20, page1.frame.size.width, page1.frame.size.height)];
[self.scroller addSubview:page1];
And do the above for every xib you want to load into the scroll view.
精彩评论