我有一个自定义 UITableView 单元,我选择了一个特定的单元并转到另一个 ViewController,当我回到第一个视图控制器时,单元的选定状态不可见。从另一个视图控制器导航后,我将如何更改单元格的选定状态?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [timeSet count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
timeSettingCell *newCell = nil;
newCell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(newCell == nil)
{
NSLog(@"newCell ===================");
NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"timeSettingCell" owner:self options:nil];
newCell = [ nibViews lastObject];
}
newCell.timeLabel.text=[timeSet objectAtIndex:indexPath.row];
if (newCell.selected==YES) {
newCell.highlighted=YES;
newCell.timeImage.image=[UIImage imageNamed:@"radioSelected.png"];
}
else {
newCell.highlighted=NO;
newCell.timeImage.image=[UIImage imageNamed:@"radioNotSelected.png"];
}
return newCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
value=[[time1 objectAtIndex:indexPath.row]integerValue];
SettingsViewController *settings=[[SettingsViewController alloc]initWithNibName:nil bundle:nil andCounterValue:value];
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
index=indexPath.row;
[settings release];
}
-(void)viewWillAppear:(BOOL)animated{
}
谢谢你