Xcode - 故事板 - UIPickerView - EXC_BAD_ACCESS

发布于 2025-01-07 09:01:52 字数 397 浏览 6 评论 0原文

我正在将 UIPickerView 与故事板一起使用。当我将 PickerView 的数据源和委托与我的视图链接时,模拟器会抛出错误(EXC_BAD_ACCESS)。当我尝试访问 ViewDidLoad 中的 PickerView 以将其移动到特定行时,会发生这种情况。

当我删除数据源和委托时。错误消失了,但我再也看不到 PickerView 了。

模拟器在这段代码处进入 main.m 并停止

    in main)int argc, char *argv[])
{
 @autoreleasepool{
        return UIApplicationMain(argc,argv,nil, NSStringFromClass([AppDelegate class]));
}
}

I am using UIPickerView with storyboard. When I link the Datasource and delegate of PickerView with my view, the simulator throw an error (EXC_BAD_ACCESS). This happens when I try to access the PickerView in my ViewDidLoad to move it to a specific row.

When I remove the datasource and the delegate. The error disappears but I do not see the PickerView anymore.

the simulator goes to main.m at this code and stops

    in main)int argc, char *argv[])
{
 @autoreleasepool{
        return UIApplicationMain(argc,argv,nil, NSStringFromClass([AppDelegate class]));
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

絕版丫頭 2025-01-14 09:01:52

这是因为设置列标题的方法之一出现错误。我将其写为 NSInteger,而它应该是 NSString

This was because of an error in one of the methods that sets the title of the columns. I wrote it as NSInteger while it should be NSString.

倒数 2025-01-14 09:01:52

我也遇到了同样的问题,因为我没有将 UIPickerView's delegatedataSource 保留为属性。如果您使用ARC,请确保管理器对象保持活动状态,并且不会自动释放

Same problem occured to me because I was not keeping the UIPickerView's delegate and dataSource as a property. If you are using ARC, make sure that the manager object stays alive and not auto-released.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文