0

我只是在做一个开关,它会改变 tableview 上的颜色。

我有 MasterViewController,它具有“tableview”颜色、数据等。我还有称为 InfoViewController 的设置控制器,它有开关。

我无法从 InfoViewController 更改颜色值。

InfoViewController 切换代码:

-(IBAction)switch:(id)sender
{
    MasterViewController *destViewController = [[MasterViewController alloc] initWithNibName:nil bundle:nil];

    static NSString *CellIdentifier = @"ElementCell";
    UITableViewCell *cell = [destViewController.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (color == @"Black") {
        cell.textLabel.textColor = [UIColor whiteColor];
        destViewController.tableView.backgroundColor = [UIColor blackColor];
        destViewController.tableView.separatorColor = [UIColor whiteColor];

    }else if(color == @"White"){
        destViewController.tableView.backgroundColor = [UIColor whiteColor];
        destViewController.tableView.separatorColor = [UIColor blackColor];
        cell.textLabel.textColor = [UIColor blackColor];
    }
}

我正在使用故事板。

4

1 回答 1

0

你有一个新的实例MasterViewController并且什么也没做,你应该改变内存中已经存在的实例的值

于 2012-11-22T02:59:57.713 回答