我使用的是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