手动创建窗口,有问题,见代码,求帮助
delegate.h
@interface snAppDelegate : UIResponder <UIApplicationDelegate>
{
//snViewController *viewControl;
UIViewController *viewControl;
UIWindow *window;
}
@property (strong, nonatomic) UIWindow *window;
@end
deletate.m@implementation snAppDelegate
@synthesize window = _windows;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//snViewController *viewControl = [[snViewController alloc] initWithNibName:@"snviewcontroller" bundle:nil];
snViewController *viewControl = [[snSecondViewController alloc] initWithNibName:@"snSecondViewController" bundle:nil];
self.window.rootViewController = viewControl;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application{}
- (void)applicationDidEnterBackground:(UIApplication *)application{}
- (void)applicationWillEnterForeground:(UIApplication *)application{}
- (void)applicationDidBecomeActive:(UIApplication *)application{}
- (void)applicationWillTerminate:(UIApplication *)application{}
@end
viewController.h
#import <UIKit/UIKit.h>
@interface snSecondViewController : UIViewController
@end
viewController.m
#import "snSecondViewController.h"
@interface snSecondViewController ()
@end@implementation snSecondViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
delegate.h
@interface snAppDelegate : UIResponder <UIApplicationDelegate>
{
//snViewController *viewControl;
UIViewController *viewControl;
UIWindow *window;
}
@property (strong, nonatomic) UIWindow *window;
@end
deletate.m@implementation snAppDelegate
@synthesize window = _windows;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//snViewController *viewControl = [[snViewController alloc] initWithNibName:@"snviewcontroller" bundle:nil];
snViewController *viewControl = [[snSecondViewController alloc] initWithNibName:@"snSecondViewController" bundle:nil];
self.window.rootViewController = viewControl;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application{}
- (void)applicationDidEnterBackground:(UIApplication *)application{}
- (void)applicationWillEnterForeground:(UIApplication *)application{}
- (void)applicationDidBecomeActive:(UIApplication *)application{}
- (void)applicationWillTerminate:(UIApplication *)application{}
@end
viewController.h
#import <UIKit/UIKit.h>
@interface snSecondViewController : UIViewController
@end
viewController.m
#import "snSecondViewController.h"
@interface snSecondViewController ()
@end@implementation snSecondViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
为什么右边要写成windows
不过我跑了一下,没什么问题
2013-06-07 16:51:56.512 emptySample[21900:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/dongzhongyuan/Library/Application Support/iPhone Simulator/5.1/Applications/2B7C04D7-AAB4-4DEB-AFC2-BE2D293A5F2B/emptySample.app> (loaded)' with name 'snSecondViewController''
*** First throw call stack:
(0x14b2022 0xeb2cd6 0x145aa48 0x145a9b9 0x236638 0xdc1fc 0xdc779 0xdc99b 0x3b401 0x3b670 0x3b836 0x4272a 0x2a67 0x13386 0x14274 0x23183 0x23c38 0x17634 0x139cef5 0x1486195 0x13eaff2 0x13e98da 0x13e8d84 0x13e8c9b 0x13c65 0x15626 0x27fd 0x2765 0x1)
terminate called throwing an exception
求大神