我有一个表格视图,其中一行在两个附件视图之间切换。问题是当我让它显示非默认附件视图时,我无法让它切换回来。
这是我正在尝试的方法。如果 actionAlertBadge 隐藏,则索引 1 处的行的附件视图应该是附件,它就是。如果 actionAlertBadge 未隐藏,则索引 1 处的行的附件视图是 actionAlertBadge。如果附件是 actionAlertBadge,如果选择了索引 1 处的行,它应该更改为附件,但它没有。
在 cellForRowAtIndexPath 中
if (!(indexPath.row == 1))
{
cell.accessoryView = accessory;
}
badgeNumber = [NSString stringWithFormat:@"%d", [[UIApplication sharedApplication]applicationIconBadgeNumber]];
actionAlertBadge = [JSCustomBadge customBadgeWithString:badgeNumber];
actionAlertBadge.frame = CGRectMake(83, 6, 30, 30);
if ([badgeNumber isEqualToString:@"0"])
{
actionAlertBadge.hidden = YES;
}
if (actionAlertBadge.hidden == NO)
{
if (indexPath.row == 1)
{
cell.accessoryView = actionAlertBadge;
}
}
else
{
if (indexPath.row == 1)
{
cell.accessoryView = accessory;
}
}
在 didSelectRowAtIndexPath
else if (indexPath.row == 1)
{
ActionAlertsIpad *actionAlerts = [[ActionAlertsIpad alloc]initWithStyle:UITableViewStyleGrouped];
WebViewControllerIpad *wvc = [[WebViewControllerIpad alloc]init];
[actionAlerts setWebViewController:wvc];
actionAlerts.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[[UAPush shared] resetBadge];
actionAlertBadge.hidden = YES;
[self.navigationController pushViewController:actionAlerts animated:YES];
}