I have a tableview being controlled by a segmented controller. My table contains info from an object with 2 properties, type and advice. if segment 0 is pressed the table fills with object advice property of type 0, if it is 1 it fills with type 1. here my issue, by default 0 shows and shows only type 0 but it repeats a few of the advice rows at the bottom.
if i press 1 it shows some type 0 then all of type 1.
segment code:
table code:
any suggestions?
thanks
if i press 1 it shows some type 0 then all of type 1.
segment code:
Code:
-(IBAction)segmentChange:(id)sender
{
if (segment.selectedSegmentIndex == 0)
{
[self.tableView reloadData];
}
if (segment.selectedSegmentIndex == 1)
{
[self.tableView reloadData];
}
}
table code:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
adviceDomain *ad = [adviceList objectAtIndex:indexPath.row];
NSLog(@"segment selected: %i",segment.selectedSegmentIndex);
// Configure the cell...
if(segment.selectedSegmentIndex == 0)
{
if([ad.type isEqualToString:@"Artists"])
{
cell.textLabel.text = ad.advice;
}
}
if(segment.selectedSegmentIndex == 1)
{
if([ad.type isEqualToString:@"Producers"])
{
cell.textLabel.text = ad.advice;
}
}
cell.textLabel.font = [UIFont systemFontOfSize:17];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
return cell;
}
any suggestions?
thanks
Last edited by a moderator: