Problem with a tableview
this is the delegate method of a tableview
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (check == TRUE){
}
Check is a bool value, then I w开发者_运维百科ant that if check is true, it should skip the creation of a cell. How can I do?
At this point you can't, you HAVE to return a cell from that method otherwise you get an exception. The key is to do the check before returning the number of rows in the section....
Cell creation is depend on numberOfRowsInSection method return 0 when you don't want any cell.
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
return value;
}
Hum, according to the UITableView Reference:
cellForRowAtIndexPath:
Returns the table cell at the specified index path.
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
(...)
Return Value
An object representing a cell of the table or nil if the cell is not visible or indexPath is out of range.
So you should be just fine returning nil, and the cell will be hidden, I guess.
Is this what you want?
精彩评论