简体   繁体   English

iPhone 应用程序无法在 iPhone 5s iOS 9.2 上运行

[英]iPhone application not working on iPhone 5s iOS 9.2

My iPhone application having checkmark functionality on tableview ,all is working fine on iPhone 6 but Facing issue with iPhone 5s.If I select row,check mark functionality not working.I am not able to figure out the exact cause.How can I check the problem?我的 iPhone 应用程序在tableview上具有复选标记功能,在 iPhone 6 上一切正常,但 iPhone 5s 面临问题。如果我选​​择行,复选标记功能不起作用。我无法找出确切原因。如何检查问题? Please help me.请帮我。 here is my UITableView这是我的UITableView

delegate method code:委托方法代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   selectedTransIdArray = [NSMutableArray arrayWithArray:userSession.transactionArray];   
NSLog(@"selectedTransIdArray first %@",selectedTransIdArray);

NSString *state = [dataTransArray objectAtIndex:indexPath.row];

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if(cell.accessoryType == UITableViewCellAccessoryNone)
{
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [selectedTransIdArray addObject:state];
    userSession.transactionArray = selectedTransIdArray;
}
else
{
    cell.accessoryType = UITableViewCellAccessoryNone;
    [selectedTransIdArray removeObject:state];
    userSession.transactionArray = selectedTransIdArray;
}

NSLog(@"selectedTransIdArray %@",selectedTransIdArray);
userSession.transactionArray = selectedTransIdArray;
[[NSUserDefaults standardUserDefaults] setObject:selectedTransIdArray forKey:@"aKey"];
[[NSUserDefaults standardUserDefaults] synchronize];

} }

u have to write a algorithm which tell u that this row data is checked or not.您必须编写一个算法来告诉您是否检查了该行数据。 and accordingly change value of checked objectatindex value并相应地更改选中的 objectatindex 值的值

if (indexPath.row == checked){
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
    cell.accessoryType = UITableViewCellAccessoryNone;
}

I think the condition you are checking is not behaving as you expected.我认为您正在检查的条件不符合您的预期。 Checking for cell's accessory type is not working, instead can you check whether the state is present in selectedTransIdArray like this检查单元格的附件类型不起作用,您可以像这样检查selectedTransIdArray是否存在state

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   selectedTransIdArray = [NSMutableArray arrayWithArray:userSession.transactionArray];   
NSLog(@"selectedTransIdArray first %@",selectedTransIdArray);

NSString *state = [dataTransArray objectAtIndex:indexPath.row];

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if(![selectedTransIdArray containsObject:state])
{
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [selectedTransIdArray addObject:state];
}
else
{
    cell.accessoryType = UITableViewCellAccessoryNone;
    [selectedTransIdArray removeObject:state];
}

NSLog(@"selectedTransIdArray %@",selectedTransIdArray);
userSession.transactionArray = selectedTransIdArray;
[[NSUserDefaults standardUserDefaults] setObject:selectedTransIdArray forKey:@"aKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM