gpt4 book ai didi

ios - Main.storyboard 未加载

转载 作者:行者123 更新时间:2023-12-01 17:52:54 27 4
gpt4 key购买 nike

我是 iOS 新手,我正在做一些我一开始就卡住的练习。我想使用如下所示的标准 Main.storyBoard:
enter image description here

AppDelegate.m 文件如下所示:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// CGRect bounds = [[UIScreen mainScreen] bounds];
// self.window = [[UIWindow alloc] initWithFrame:bounds];
//
// self.controler = [[ViewController alloc] init];
//
// self.window.rootViewController = self.controler;
//
// [self.window makeKeyAndVisible];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *vc = [storyboard instantiateInitialViewController];

// Set root view controller and make windows visible
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];



return YES;
}

和 ViewControler 是否有用:
@interface ViewController ()

@property UIView *viewM;

@end

@implementation ViewController

-(void) loadView
{
CGRect bounds = [[UIScreen mainScreen] bounds];

self.viewM = [[UIView alloc] initWithFrame: bounds];
self.view = self.viewM;

}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"AHAHH DOTKNIETO EKRANU");
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
self.view.backgroundColor = [UIColor blueColor];
}

- (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = [UIColor whiteColor];


UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 200, 200, 50)];

//SET TEXT FOR THIS LABEL

label.text = @"TEXTTTTTT";
[self.view addSubview:label];

// Do any additional setup after loading the view, typically from a nib.
}

每次我运行这个示例时,它都会加载我的 View ,它是白色的,而不是上面的图像。它有什么不对?我正在使用 Xcode 5.1.1 版本。

最佳答案

在项目 - 常规页面中,您应该看到“主界面”的设置。

删除applicationDidFinishLaunching中的所有代码除了 return YES;并确保将其设置为 Main .

enter image description here

关于ios - Main.storyboard 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23937019/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com