我通常只是爲我的iOS使用storyboard,但需要集成一個不使用storyboard而非xib的SDK。我最初的視圖控制器來自故事板,當按下按鈕(IBAction)時,我希望它進入xib視圖控制器,但不確定程序如何執行此操作。這是我的AppDelegate:從ViewController(storyboard)調用NavigationController(xib)
//AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:...{
// set to storyboard on launch
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"iPhoneStoryboard"
bundle: nil];
UIViewController* viewController = [mainStoryboard instantiateInitialViewController];
[self.window setRootViewController:viewController];
[window makeKeyAndVisible];
return YES;
}
這裏是我的代碼的.h:
//mainVC.h
#import <UIKit/UIKit.h>
@interface MainVC : UIViewController{
UIWindow *window;
UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UIButton *buttonScan;
-(IBAction) ActionScan;
@end
與.m:
//mainVC.m
@interface MainVC()
@end
@implementation MainVC
@synthesize window;
@synthesize navigationController;
@synthesize buttonScan;
- (IBAction)ActionScan{
window.rootViewController = navigationController;
[window makeKeyAndVisible];
}
沒有奏效。我添加了AppDelegate.m,以便它可以幫助 – Bachzen
它應該工作。什麼是錯誤 –
在這裏粘貼你的代碼 –