选择器视图上的断言失败 [英] Assertion failure on picker view

查看:186
本文介绍了选择器视图上的断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

滚动一个选择器视图w /零数据(零行)时,我得到一个断言失败。当滚动选择器视图时,我得到这个崩溃。在iOS 6上测试

I'm getting an assertion failure while scrolling a picker view w/ zero data(zero rows). While scrolling the picker view I'm getting this crash. Testing on iOS 6


* - [UITableViewRowData rectForRow:inSection:],/ SourceCache / UIKit_Sim /UIKit-2372/UITableViewRowData.m:1630

* Assertion failure in -[UITableViewRowData rectForRow:inSection:], /SourceCache/UIKit_Sim/UIKit-2372/UITableViewRowData.m:1630

* 由于未捕获异常NSInternalInconsistencyException终止应用程序,原因:
无效的索引路径(2个索引[0,0])'

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect at invalid index path ( 2 indexes [0, 0])'

任何帮助都是可以理解的。

Any help is appreciable.

推荐答案

我有同样的问题

我不知道为什么发现,

但它可以在ios6中修复(在ios5中如何工作,我没有检查):

but it can be fixed in ios6 (how it works in ios5 I didn't check):

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if ([self getCount] == 0)
        return 1;
     return [self getCount];
}

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:   (NSInteger)component reusingView:(UIView *)view {
   if ([self getCount] == 0)
       return nil;
}

这篇关于选择器视图上的断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆