use*_*951 2 iphone xcode objective-c uitableview ios
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
我认为如果表是空的,即
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[BNUtilitiesQuick getBizs] count];
}
Run Code Online (Sandbox Code Playgroud)
总是返回 0
我希望-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath根本不应该调用
这个很重要。我正在制作一个程序来搜索事物,有时经过一些搜索,没有返回任何结果。
但是,无论如何都被调用了,我得到了一个例外。我该怎么办?
-tableview:cellForRowAtIndexPath: 可能在表视图意识到它有零行之前被调用,因此不应被调用。
因此,您的实现需要检查传入的行的值是否超出数组的范围。如果是,您需要返回一个空单元格(文档说明返回nil将引发异常)。