我有一個UITableView
稱爲symptomtable ......並有remedytable當UISwitch
是在remedytable我對symptomtableviewcell顯示UIImage
以突出UISwitch
爲ON該小區。當我切換ON在remedytable第一症狀的我顯示UISwitch
但所述細胞得到再利用,並且圖像被在其他symptomtableview細胞表示爲好。任何人都可以幫我解決這個問題嗎?UITableViewCell中得到重用
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView==symptomsTableView)
{
PPsymptomTableCell *cell;
static NSString *[email protected]"cellIdentifier";
cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil)
{
cell=[[PPsymptomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
int symptomIDSelected;
symptomIDSelected = [[[mainsymptArray objectAtIndex:indexPath.row]objectForKey:@"SymptID"]intValue];
NSLog(@"%d",[[activeNotificationDictionary objectForKey:[NSNumber numberWithInt:symptomIDSelected]]intValue]);
for (int i = 0; i<activeNotificationDictionary.count; i++)
{
if([[activeNotificationDictionary objectForKey:[NSNumber numberWithInt:symptomIDSelected]]intValue] == symptomIDSelected)
{
cell.selectedCellImageDisplay.hidden=NO;
}
else
{
cell.selectedCellImageDisplay.hidden=YES;
}
}
NSLog(@"end of symptoms cell for row");
if (searching==YES)
{
cell.symptomCellLabel.text=[[searchSymptomsArray objectAtIndex:indexPath.row] objectForKey:@"SymptName"];
cell.backgroundColor=[UIColor clearColor];
return cell;
}
else
{
cell.backgroundColor=[UIColor clearColor];
NSArray *sectionArray=[mainIndexDictionary objectForKey:[allKeysArray objectAtIndex:indexPath.section]];
cell.symptomCellLabel.text=[[sectionArray objectAtIndex:indexPath.row] objectForKey:@"SymptIndexName"];
return cell;
}
}
這裏activenotification字典是NSMutableDictionary
其含有remedyID的該特定symptomID的值。 這是symptomtable
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.symptomCellImageView.contentMode=UIViewContentModeScaleToFill;
selectedCellImageDisplay = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"selectedSymptomImage.png"]];
selectedCellImageDisplay.frame = CGRectMake(230.0, 8.0, 30.0, 30.0);
selectedCellImageDisplay.hidden=YES;
symptomCellLabel=[[UILabel alloc]initWithFrame:CGRectMake(15.0,0.0 ,280.0,40.0)];
symptomCellLabel.font=[UIFont fontWithName:@"Rockwell" size:17];
symptomCellLabel.textColor=[UIColor blackColor];
symptomCellLabel.backgroundColor=[UIColor clearColor];
[self.contentView addSubview:symptomCellLabel];
[self.contentView addSubview:selectedCellImageDisplay];
// Initialization code
}
return self;
}
我在上customcell – 2013-02-16 15:55:24
稱爲remedyTableView另一個tableview中你使用兩個UITableViews您的應用程序的同一部分添加UISwitch? – bdesham 2013-02-16 17:47:34
是的,我有兩個UITableviews ......當我在一個點擊的UITableView它導航到另一個UITableView的 – 2013-02-23 16:20:36