I have tableview. When I scrolling my tableview my text label in table cells is mixing. How to fix it?
My code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell3";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
UILabel *label = (UILabel *)[self.view viewWithTag:1];
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0:
label.text = [_array objectAtIndex:indexPath.row];
break;
case 1:
label.text = [_array objectAtIndex:indexPath.row];
break;
case 2:
label.text = [_array objectAtIndex:indexPath.row];
break;
}}