2014-10-02 38 views
0

我正在爲iOS 8編寫一個應用程序。我有一個問題,因爲我不想使用Storyboard,我想在第一次放入一個.xib文件。 Muy的問題是,總是在飛濺之後成爲黑屏。想要在Splash後添加一個.Xib的黑色畫面

我想飛濺後放誰的類是LoginViewController

在常規選項中,「主界面」是白色的(空)(如果把類的名字,我NSException(NSUknownException)) 。

在.xib文件中,我有文件所有者連接,並且在屏幕的右側,我在「自定義類」(LoginViewController)中具有該類的名稱。

我appDelegate.h是:(我嘗試用 「@財產(強,非原子)LoginViewController *的viewController;」 太)

#import <UIKit/UIKit.h> 
#import "LoginViewController.h" 

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UIWindow *window; 
@property (strong, nonatomic) UIViewController *viewController; 


@end 

我appDelegate.m是:(我嘗試了很多變種)

#import "AppDelegate.h" 
#import "LoginViewController.h" 

@interface AppDelegate() 

@end 

@implementation AppDelegate 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    self.viewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; 

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 
    navController.navigationBarHidden = YES; 

    self.window.rootViewController = navController; 
    [self.window makeKeyAndVisible]; 

    return YES; 

} 

- (void)applicationWillResignActive:(UIApplication *)application { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application { 
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 
} 

- (void)applicationDidBecomeActive:(UIApplication *)application { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 

- (void)applicationWillTerminate:(UIApplication *)application { 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 

@end 

的LoginViewController.h:

#import <UIKit/UIKit.h> 

@interface LoginViewController : UIViewController 
{ 

    IBOutlet UILabel *labelPrueba; 
    IBOutlet UIButton *botonPrueba; 

    IBOutlet UIButton *boton2prueba; 
    IBOutlet UILabel *label2Prueba; 

    IBOutlet UILabel *dsfd; 
    IBOutlet UIButton *dfdf; 
} 

@end 

的LoginViewController.m:

#import "LoginViewController.h" 

@interface LoginViewController() 

@end 

@implementation LoginViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 

    label2Prueba.text = @"laaaaaaaaaaaaa"; 
    NSLog(@"Entra en viewDidLoad"); 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 
*/ 

@end 

有人可以幫助我。我要瘋了。

非常感謝。

回答

0

將其放入這個窗戶像初始化框架:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    // That was the solution 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // That was the solution 

    self.viewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; 

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 
    navController.navigationBarHidden = YES; 

    self.window.rootViewController = navController; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

感謝

相關問題