2014-02-18 115 views
1

我有一個表格視圖,其中一行可在兩個附件視圖之間切換。問題是,當我有它顯示非默認配件視圖,我無法讓它切換回來。更改單元格附件視圖

這是我如何去做。如果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]; 
    } 

回答

1

我通過行選擇碼加法[tableView reloadData];固定這一點。

相關問題