在Xcode 7.1中,当我创建一个新项目时,storyBoard是默认的。我想使用xib文件开发一个具有多个屏幕的应用程序。请告诉我们如何做到这一点?
无论如何,你能告诉我如何使用xib逐步构建一个简单的项目。非常感谢你。
答案 0 :(得分:0)
如果您想拥有多个XIB,请按照以下步骤进行操作
First remove the storyboard file from your project
In Deployment Info of TARGETS,delete Main from Main Interface
The create the View(XIB). Give the name as ViewController.Xib
然后在appDelegate.h
import - #import "ViewController.h"
@property (strong, nonatomic) ViewController *vc;
然后在appDelegate.m
@synthesize vc;
然后在didFininshLaunchingWithOptions
中 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
vc = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navigationVC = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navigationVC;
self.window.backgroundColor = [UIColor clearColor];
[self.window makeKeyAndVisible];
return YES;
}
接下来,如果想要创建多个xib,可以根据需要使用.h,.m和xib创建它。