Ios 删除情节提要并使用.xib启动应用程序
我试着按照上面的说明来做。但是我一定没有做正确的事情,因为在我进入ViewController方法之前,我仍然得到一个SIGABRT 以下是步骤:Ios 删除情节提要并使用.xib启动应用程序,ios,objective-c,xcode,xcode-storyboard,Ios,Objective C,Xcode,Xcode Storyboard,我试着按照上面的说明来做。但是我一定没有做正确的事情,因为在我进入ViewController方法之前,我仍然得到一个SIGABRT 以下是步骤: 复制故事板中视图上的所有项目,并粘贴到新的xib视图中 已将.h和.m视图控制器文件的所有内容复制到xib的新文件中 在info.plist文件中将主nib文件基名称更改为新的xib名称 试图更改所有者,但我不知道是否正确 按如下方式编辑appdelegate didFinishLaunchingWithOptions文件: - (BOOL)appl
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
帮助?您是否在xib文件的identity inspector中分配了相应的类
您需要创建一个空应用程序,然后按cmd+n并选择
coca-touch>objective-c class
。将类命名为RootViewController并保留子类(UIViewController
),然后用XIB检查用户界面的
完成此操作后,进入AppDelegate.m文件,在-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions下添加以下代码返回:YES
self.RootViewController = [[RootViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.RootViewController];
self.navController.navigationBarHidden = YES;
[self.window addSubview:self.navController.view];
所以,现在应该是这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
self.RootViewController = [[RootViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.RootViewController];
self.navController.navigationBarHidden = YES;
[self.window addSubview:self.navController.view];
return YES;
}
#import <UIKit/UIKit.h>
@class RootViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) RootViewController *RootViewController;
@property (strong, nonatomic) UINavigationController *navController;
@end
然后,在#import“AppDelegate.h”的下方添加#import“RootViewController.h”
。完成此操作后,转到AppDelegate.h文件,并添加@class RootViewController代码>位于@界面上方。然后,在@interface-AppDelegate
下添加以下代码:
@property (strong, nonatomic) RootViewController *RootViewController;
@property (strong, nonatomic) UINavigationController *navController;
因此,您的整个AppDelegate.h
现在应该如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
self.RootViewController = [[RootViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.RootViewController];
self.navController.navigationBarHidden = YES;
[self.window addSubview:self.navController.view];
return YES;
}
#import <UIKit/UIKit.h>
@class RootViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) RootViewController *RootViewController;
@property (strong, nonatomic) UINavigationController *navController;
@end
#导入
@类RootViewController;
@接口AppDelegate:UIResponder
@属性(强,非原子)UIWindow*window;
@属性(强,非原子)RootViewController*RootViewController;
@属性(强,非原子)UINavigationController*navController;
@结束
现在,您已经完成了所有这些,您应该能够开始编写您的应用程序,就像您通常为xib文件编写代码一样!祝你好运 查看您的info.plist。它是否仍然包含值为“Main”的关键UIMainstryBoardFile(“主情节提要文件基名称”)?删除此键值对,这将解决您的问题:)1。添加viewcontroller文件所有者类
2.AppDelegate.h文件
@属性(强,非原子)ViewController*ViewController
3.AppDelegate.m文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
或
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
ViewController *loginVC = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:loginVC];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
在这里重复这个问题。。。请尝试此链接。。。。这会让你明白你想做什么。。。我把上面的链接作为一个答案:(@logixologist-这是我发布的同一个链接。很好的信息。顺便说一句:我再试了一次,第二次成功了!!!:-)很好的检查。但当我第二次尝试时,从一个空的项目开始对我来说是有效的。Xcode对我来说一定不可靠了。谢谢你的帮助。