我使用的是UITableView
靜態細胞我的應用程序的設置視圖。毛刺動畫時與靜態細胞
一個該表的部分都包含兩個小區,第二個僅當包含在第一個的UISwitch
被接通是可見的。
所以UISwitch
的目標是:
- (void)notificationSwitchChanged:(id)sender
{
UISwitch* switch = (UISwitch*)sender;
self.bNotify = switch.on;
[self.settingsTable reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationTop];
}
我實現numberOfRowsInSection:
這樣:
(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
if (section != 1)
return [super tableView:tableView numberOfRowsInSection:section];
if (self.bNotify)
return 2;
return 1;
}
這個 「作品」,但動畫發生故障,使得第一個單元格消失或根據我選擇的動畫類型,向上滑動到上一部分下方或各種東西的上方。最乾淨的是UITableViewRowAnimationNone
,但仍不完美。
如果我滾動部分拿出來看並支持它看起來恢復正常。
編輯:把問題的幾張截圖:
我嘗試過和reloadSections
後加入beginUpdates
和endUpdates
但它並沒有改變任何東西。使用reloadData
而不是reloadSections
作品,但根本沒有動畫。
是因爲表的單元格是靜態的還是我失去了一些東西?
嘗試'[self.tableView setNeedsLayout];'。 –
我嘗試在'reloadSections'後面添加它,沒有任何效果。 – Jukurrpa