私は通常、iOSにストーリーボードを使用していますが、ストーリーボードではなくxibを使用しないSDKを統合する必要がありました。私の最初のView Controllerはストーリーボードからのもので、ボタンが押されたとき(IBAction)、xib View Controllerに移動したいのですが、プログラムでそうする方法がわかりません。これが私のAppDelegateです:
//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];
}