LOTS of Default.png Q's, but I didn't read one like this: I see Default.png, but then the screen goes blank, but no error messages, no abort. What am I missing?
SDK 4.3, iPhone only, no nib, no schemes, no orientation other than portrait up/down. Nav controller, 4 tabs.
App ABC works fine.
Clone XYZ doesn’t.
info.plist seems identical, including the half dozen icon files; neither app has an entry that contains “MainWindow.” Analyze and both generate “Build succeeded.” Run and both display “Attaching to process blah-blah-blah.” Any combo of reboot and/or restart Mac/XCode/simulator/device doesn’t do a dang thing. There is one difference, though: the drop-down for ABC shows the full device name, two 4.2’s and two 4.3’s; XYZ shows only “IOS Device” and the two 4.3’s. ABC shows all the NSLogs. XYZ shows none of them. And in both cases, the first NSLog is right after
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Clean all targets made no difference. I’m thinking, “Clone NOT.”
XJones, here's the code you requested. I've whacked it down as much as I could.
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"app delegate CGRect");
CGRect frameMain = [UIScreen mainScreen].applicationFrame;
glbl_height = frameMain.size.height;
glbl_width = frameMain.size.width;
NSLog(@"app delegate background");
UIColor *blueGreenBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Default.png"]];
self.window.backgroundColor = blueGreenBackground;
[blueGreenBackground release];
NSLog(@"app delegate 3");
Method01_vc *method01VC = [[[Method01_vc alloc] init] autorelease];
// more controllers
method01VC.title = NSLocalizedString(@"Title 1, Method 1",@"(title 1)");
// more titles
UINavigationController *method01Nav = [[[UINavigationController alloc] initWithRootViewController:method01VC] autorelease];
// more controllers
NSLog(@"app delegate prior to tabBar init");
_tabBarController = [[UITabBarController alloc] init];
NSArray *sections = [NSArray arrayWithObjects:method01Nav, method02Nav, method03Nav, method04Nav, nil];
[_tabBarController setViewControllers:sections];
CGRect frame = CGRectMake(0.0, 0.0, 320, 48); // 48
UIView *tabBarView = [[UIView alloc] initWithFrame:frame];
[tabBarView setBackgroundColor:[UIColor colorWithRed:0.07 green:0.14 blue:0.04 alpha:0.8]];
NSArray *tabs = _tabBarController.v开发者_StackOverflow社区iewControllers;
UIViewController *tab1 = [tabs objectAtIndex:0];
tab1.tabBarItem.image = [UIImage imageNamed:@"tabIcon01.png"];
tab1.tabBarItem.title = @"";
UIViewController *tab2 = [tabs objectAtIndex:1];
tab2.tabBarItem.image = [UIImage imageNamed:@"tabIcon02.png"];
tab2.tabBarItem.title = @"";
NSLog(@"app delegate prior to tabBar insert");
[[_tabBarController tabBar] insertSubview:tabBarView atIndex:0];
tabBarView.autoresizesSubviews = YES;
[tabBarView release];
_tabBarController.delegate = self;
[self.window addSubview:_tabBarController.view];
// self.tabBarController.selectedIndex = 1; ---- makes no difference
// self.window.rootViewController = self.tabBarController; --- ditto
NSLog(@"app delegate prior to makeKeyAndVisible");
[self.window makeKeyAndVisible];
NSLog(@"app delegate, about to return YES");
return YES;
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
NSLog(@"Method01 CGRect");
CGRect frameMain = [UIScreen mainScreen].applicationFrame;
UIView *view = [[UIView alloc] initWithFrame:frameMain];
self.view = view;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.autoresizesSubviews = YES;
After the above, all the usual labels and text fields follow.
Thanks again for taking the time to slog through it.
I've got my hopes set on a "Duh!"
Default.png is only displayed while iOS is launching your app. B/c your app doesn't do anything it launches very quickly so Default.png goes away and is replaced by the UI of your app. Either you are not adding a view to your apps window or the view you added displays as blank.
[EDIT 1: need to create a window]
Looked at your code and if you are not using IB you need to initialize the window in the app delegate before you add the tab bar controller's view to it.
self.window = [[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];
Here's a link to a blog that show's everything you need to do if not using IB:
http://code-dojo.blogspot.com/2009/11/build-iphone-application-without.html
精彩评论