我有2个plist文件:
和
My StoryBoard是:
问题是当我的“Inicio”viewcontroller从plist加载数据时,我希望在具有ENABLE = NO属性&使用ENABLE = YES启用单元格,当我按下或单击单元格时,然后转到下一个视图控制器“PERSONAS”在此视图控制器中加载第二个Plist,在同样的情况下我只想转到“DETALLE”viewcontroller启用的单元格从plist中获得ENABLED YES。
对于每个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);
为了显示自定义单元格中的tableview我使用:
- (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视图控制器中我使用相同的代码但不工作,所有海关单元都启用了,我该如何解决?,或者我错了什么?或者我做了Forget Something,请帮助人们!! 模拟器中的以这种方式运行ENABLE:
但是我不想要ENABLE NO运行的细胞!!:
请帮助大家,我使用XCODE 5 DP6,对于iOS7,如何解决这个问题的最佳方法! 致谢!!!!
答案 0 :(得分:0)
对于很多意图,最后解决这个问题!!以及在每个viewcontroller中,代码whit解决这个问题就像:
- (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' //
//------------------------------------------//
}