Waitak Jong Waitak Jong - 5 months ago 8
iOS Question

I uitableview the (cell = nil) always not call?

in the ui tableview cell,
the statement if (cell == nil) is not called.

Because when i initialize the cell outside the if statement, the talbe will have some wrong label in wrong row.

how can I initialize my cell?

The @"tttestttt" NS LOG is not all the time when the table is created.

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

static NSString *MyIdentifier = @"GroupsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSLog(@"tttesttttt");
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
}


}

Answer

dequeueReusableCellWithIdentifier: always return a cell if you're using Storyboard.

Comments