0

好吧,我有 2 个 plist 文件:

plist1

和:

plist2

我的故事板是:

故事板

问题是当在我的“Inicio”视图控制器中从 plist 加载数据时,我希望在具有 ENABLE=NO 属性时禁用单元格并启用具有 ENABLE = YES 的单元格,当我按下或单击单元格时,然后转到此视图控制器中的下一个视图控制器“PERSONAS”加载第二个 Plist,在同样的情况下,我只想使用 plist 中启用的已启用单元格进入“DETALLE”视图控制器。

对于我使用的每个 viewdidload:

 NSString *myListPath = [[NSBundle mainBundle] pathForResource:@"MainMenuList"      ofType:@"plist"];
mainMenu = [[NSArray alloc]initWithContentsOfFile:myListPath];
NSLog(@"%@",mainMenu);

 NSString *myListPath = [[NSBundle mainBundle] pathForResource:@"PersonasList" ofType:@"plist"];
Personas = [[NSArray alloc]initWithContentsOfFile:myListPath];
NSLog(@"%@",Personas);

为了在自定义单元格中显示表格视图,我使用:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *simpleTableIdentifier = @"CustomCell";

NSLog(@"CARGANDO CELDAS");
MainMenuCell *cell = (MainMenuCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCelliPhone" owner:self options:nil];
    cell = [nib objectAtIndex:0];
}
//CustomCell*cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

cell.Enabled.text = [[mainMenu objectAtIndex:indexPath.row]objectForKey:@"ENABLE"];
cell.TitleLabel.text = [[mainMenu objectAtIndex:indexPath.row]objectForKey:@"NAME"];
cell.ImageImageView.image = [UIImage imageNamed:[[mainMenu objectAtIndex:indexPath.row]objectForKey:@"IMAGE"]];

    if ([cell.Enabled.text isEqualToString:@"NO"])
    {
        NSLog(@"%@",cell.Enabled.text);
        cell.userInteractionEnabled = NO;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.selected = NO;
        cell.accessoryType = UITableViewCellAccessoryNone;
    }

return cell;

}

在 Persona 视图控制器中,我使用相同的代码但无法正常工作,所有自定义单元都已启用,我该如何解决?或者我有什么问题?或者我确实忘记了一些东西,请帮助大家!

在模拟器中以这种方式运行以启用:

ios71

但我不想让 ENABLE NO 运行的单元格!!:

ios72

请帮助大家,我使用 XCODE 5 DP6,对于 iOS7,解决这个问题的最佳方法是什么!!!谢谢!!!!

4

1 回答 1

0

对于许多意图,终于解决了这个问题!在每个视图控制器中,解决这个问题的代码就像:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *simpleTableIdentifier = @"MainMenuCell";

NSLog(@"CARGANDO CELDAS");
MainMenuCell *cell = (MainMenuCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MainMenuCelliPhone" owner:self options:nil];
    cell = [nib objectAtIndex:0];
}
//MainMenuCell*cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

cell.Enabled.text = [[mainMenu objectAtIndex:indexPath.row]objectForKey:@"Enabled"];
cell.TitleLabel.text = [[mainMenu objectAtIndex:indexPath.row]objectForKey:@"Title"];
cell.ImageImageView.image = [UIImage imageNamed:[[mainMenu objectAtIndex:indexPath.row]objectForKey:@"Image"]];
//cell.ImageImageView.image = [[mainMenu objectAtIndex:indexPath.row]objectForKey:@"Image"];

    if ([[[mainMenu objectAtIndex:indexPath.row]objectForKey:@"Enabled"] isEqualToString:@"NO"])
    {
        NSLog(@"%@",cell.Enabled.text);
        cell.userInteractionEnabled = NO;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.selected = NO;
        cell.accessoryType = UITableViewCellAccessoryNone;

        cell.ImageImageView.image = [UIImage imageNamed:@"NO.png"];
    }
    else
    {
    cell.ImageImageView.image = [UIImage imageNamed:@"YES.png"];
    }

return cell;

    //------------------------------------------//
    //               THANKS anyway              //
    //          GRETTINGS FROM BOLIVIA          //
    //                ROCK ON!!!! n_n'          //
    //------------------------------------------//
 }
于 2013-09-18T19:14:12.233 回答