RootViewController не загружается в NIB

Я пытаюсь следовать примеру функций для библиотеки Inferis/ViewDeck здесь. Однако контроллер корневого представления загружается, но не переходит к моему представлению входа в систему. Я использую режим входа в систему вместо режима просмотра выбора колоды.

APAppDelegate.h

#import <UIKit/UIKit.h>
@class LoginController;

@interface APAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

APAppDelegate.m

#import "APAppDelegate.h"
#import "RootViewController.h"

@implementation APAppDelegate

@synthesize window = _window;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    RootViewController *rootController = (RootViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"RootViewController"];
    self.window.rootViewController = rootController;//[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    [self.window makeKeyAndVisible];
    return YES;
}

Мне пришлось использовать MainStoryboard для себя, потому что я использую раскадровку, а он использует xib. Пытаясь initwithNibName в appdelegate, я получил сообщение об ошибке, в котором говорилось, что RootViewController не существует.

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
{

}

@property (nonatomic, retain) IBOutlet UIView *loginView;
@property (nonatomic, retain) UINavigationController *navController;

@end

RootViewController.m

#import "RootViewController.h"
#import "IIViewDeckController.h"
#import "LoginController.h"
#import "SideMenuView.h"
#import "APCustomerViewController.h"

@implementation RootViewController
@synthesize loginView = _loginView;
@synthesize navController = _navController;
- (void)viewDidLoad
{
    NSLog(@"RootViewController viewDidLoad");
    [super viewDidLoad];

    // Override point for customization after application launch.
    LoginController *loginController = [[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];

    self.navController = [[UINavigationController alloc] initWithRootViewController:loginController];
    self.navController.navigationBar.tintColor = [UIColor darkGrayColor];

    self.navController.view.frame = self.loginView.bounds;
    [self.loginView addSubview:self.navController.view];
    NSLog(@"End RootViewController viewDidLoad");
}

Логинконтроллер.h

#import <UIKit/UIKit.h>
@class KeychainItemWrapper;
@class DataClass;

@interface LoginController : UITableViewController <UITextFieldDelegate>
{
    IBOutlet UITextField *userField;
    IBOutlet UITextField *passwordField;
    IBOutlet UISwitch *saveLogin;
    UIActivityIndicatorView *activitySpinner;
    KeychainItemWrapper *keychain;
    DataClass *dataObj;

    id delegate;
}

@property (nonatomic, retain) IBOutlet UITextField *userField;
@property (nonatomic, retain) IBOutlet UITextField *passwordField;
@property (nonatomic, retain) IBOutlet UISwitch *saveLogin;
@property (nonatomic, retain) id delegate;

@end

ЛогинКонтроллер.m

- (void)viewDidLoad
{
    NSLog(@"LoginController viewDidLoad");
    [super viewDidLoad];
    [userField setDelegate:self];
    [passwordField setDelegate:self];
    TextFieldDelegate *myDelegate = [[TextFieldDelegate alloc] init];
    [self setDelegate:myDelegate];
    //set the delegate's currentViewController property so that we can add a subview to this View. 


    activitySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    activitySpinner.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
    activitySpinner.center = self.view.center;
    [self.view addSubview:activitySpinner];

    keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"APLogin" accessGroup:nil];
    [userField setText:[keychain objectForKey:(__bridge id)kSecAttrAccount]];
    [passwordField setText:[keychain objectForKey:(__bridge id)kSecValueData]];

    if ([userField text] != @"" && [passwordField text] != @"") {
        [saveLogin setOn:YES];
    }

    dataObj = [DataClass getInstance];

    // Do any additional setup after loading the view from its nib.
}

Журнальный файл

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov  3 21:59:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 18487.
2012-01-20 11:56:11.586 Appointment-Plus[18487:f803] RootViewController viewDidLoad
2012-01-20 11:56:11.589 Appointment-Plus[18487:f803] End RootViewController viewDidLoad

У меня все имена классов в перьях раскадровки такие же, как и в файлах классов. Как вы можете видеть, RootViewController viewDidLoad работает полностью, но LoginController вообще не работает. Я пытаюсь запустить LoginController из RootViewController.

Моя конечная цель - получить меню в стиле facebook, которое выдвигается, но только на некоторых страницах. Страницы, которые будут использовать меню, располагаются после LoginController.

1.) Пользователь открывает приложение и получает страницу входа 2.) Пользователь входит в систему и получает главную страницу с меню в стиле facebook ios 3.) Когда пользователь щелкает элемент, он может перейти на новую страницу, которая не будет иметь стороны меню.

Насколько я понимаю, для управления всем этим необходим RootViewController.


person Bot    schedule 20.01.2012    source источник


Ответы (1)


Я решил не использовать библиотеку, а просто использовал корневой контроллер представления и создал собственное слайд-меню.

person Bot    schedule 24.01.2012