gpt4 book ai didi

iPhone App 在创建 UIButton 时在 loadView 方法中崩溃

转载 作者:行者123 更新时间:2023-11-28 18:08:02 25 4
gpt4 key购买 nike

为什么每当加载此 View 时,我的应用程序就会崩溃?

-(void)loadView {
UIButton *chooseSubjectButton = [[UIButton buttonWithType:UIButtonTypeDetailDisclosure] retain];
[chooseSubjectButton addTarget:self action:@selector(chooseSubject) forControlEvents:UIControlEventTouchUpInside ];
chooseSubjectButton.frame = CGRectMake(15.0f, 205.0f, 296.0f, 51.0f);
[self.view addSubview:chooseSubjectButton];
}

如有任何帮助,我们将不胜感激。

谢谢!

最佳答案

我的猜测是,您的应用实际上并没有崩溃。它只是不断重复调用 loadView 方法,因为您错过了加载 View 。在向 self.view 添加任何内容之前,调用 [super loadView] 或创建一个 View 并将其指定为 self.view。方便的方法是使用 [super loadView]

- (void)loadView {

[super loadView];
// Your Code Here
}

编辑:这个答案看起来是错误的。请考虑访问 Is it ok to call [super loadView]?正如@Denis Vert 在评论中指出的那样。

关于iPhone App 在创建 UIButton 时在 loadView 方法中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6152401/

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