Xcode - 故事板 - UIPickerView - EXC_BAD_ACCESS
我正在将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为设置列标题的方法之一出现错误。我将其写为
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 beNSString
.我也遇到了同样的问题,因为我没有将
UIPickerView's
delegate
和dataSource
保留为属性。如果您使用ARC
,请确保管理器对象保持活动状态,并且不会自动释放
。Same problem occured to me because I was not keeping the
UIPickerView's
delegate
anddataSource
as a property. If you are usingARC
, make sure that the manager object stays alive and notauto-released
.