0
프로그래밍 방식으로 탭 표시 줄 컨트롤러를 초기화하고 싶지만 방금 가지고있는 코드가있는 빈 화면이 나타납니다. 나는 TheElements sample app을 모방하려고 노력했는데, 물건들은 필적할만한 줄 단위로 보인다. 그러나 분명히 뭔가 잘못되었다. 어떤 제안?iphone 초기화 프로그램에서 탭 표시 줄 컨트롤러보기
감사합니다 ... main.m에서
: DubbleWrapAppDelegate.h에서
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"DubbleWrapAppDelegate");
[pool release];
return retVal;
}
: DubbleWrapAppDelegate.m에서
@interface DubbleWrapAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
:
@implementation DubbleWrapAppDelegate
@synthesize window;
@synthesize tabBarController;
- init {
if (self = [super init]){
// initialize to nil
window = nil;
tabBarController = nil;
}
return self;
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
SafeTableViewController *vc1 = [[SafeTableViewController alloc] initWithStyle:UITableViewStylePlain];
[vc1 setSafeItems:[SafeItem knownSafeItems]]; // Set the list of known SafeItems:
UINavigationController *nc1;
nc1 = [[UINavigationController alloc] initWithRootViewController:vc1];
[vc1 release];
BoxXRayTableViewController *vc2 = [[BoxXRayTableViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *nc2;
nc2 = [[UINavigationController alloc] initWithRootViewController:vc2];
[vc2 release];
AboutLibertyViewController *vc3 = [[AboutLibertyViewController alloc] init];
UINavigationController *nc3;
nc3 = [[UINavigationController alloc] initWithRootViewController:vc3];
[vc3 release];
NSArray* controllers = [NSArray arrayWithObjects:nc1, nc2, nc3, nil];
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = controllers;
[controllers release];
// Add the tab bar controller's current view as a subview of the window
window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[window setBackgroundColor:[UIColor redColor]];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
[nc1 release];
[nc2 release];
[nc3 release];
}
PLIST 없음으로 설정됩니다. 참조 된 NIB 파일.
을 아. self.window = window를 추가하면 (어쩌면 내가 잘못된 위치에 놓았을 때) dealloc 함수에서 release 한 이후 autorelease 메시지를 제거하는 것이 효과가있었습니다. 감사!!! – unsorted