当前位置: 代码迷 >> Iphone >> 关于手动创设窗口
  详细解决方案

关于手动创设窗口

热度:28   发布时间:2016-04-25 06:01:21.0
关于手动创建窗口
手动创建窗口,有问题,见代码,求帮助
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

------解决方案--------------------
snViewController *viewControl这个地儿你不报错么、不应该是snSecondViewController么
------解决方案--------------------
@synthesize window = _windows;
为什么右边要写成windows
不过我跑了一下,没什么问题
------解决方案--------------------
  相关解决方案