cyclingIsBetter
cyclingIsBetter

Reputation: 17581

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 want that if check is true, it should skip the creation of a cell. How can I do?

Upvotes: 1

Views: 223

Answers (4)

N. Anant Vijay
N. Anant Vijay

Reputation: 43

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {

return value;

}

Upvotes: 0

tnull
tnull

Reputation: 758

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?

Upvotes: -1

Rahul Vyas
Rahul Vyas

Reputation: 28720

Cell creation is depend on numberOfRowsInSection method return 0 when you don't want any cell.

Upvotes: 0

Simon Lee
Simon Lee

Reputation: 22334

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....

Upvotes: 2

Related Questions