在關閉表編輯模式後,我仍然有一個editingAccessoryView
的editingAccessoryView
問題。表編輯完成後,UISwitch在UITableViewCell中仍然可以略微顯示
當前我正在使用UISwitch
作爲編輯配件視圖,並讓表視圖句柄在按下導航欄的編輯按鈕時通過動畫移動編輯視圖的開啓/關閉屏幕。
幾乎所有的編輯配件都可以在屏幕外正確顯示動畫,但總是有兩個不能使其脫離屏幕,然後在單元出列並重新使用時重用它們,以便在滾動過程中顯示它們。
有沒有其他人看到這個或有什麼我在這裏失蹤?
我設立這樣的細胞:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AllStatCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AllStatCell"];
if (cell.editingAccessoryView == nil) {
UISwitch *statSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
[statSwitch addTarget:self action:@selector(saveSwitchState:) forControlEvents:UIControlEventValueChanged];
cell.editingAccessoryView = statSwitch;
}
NSString *statName = [self statNameForIndexPath:indexPath];
cell.statName.text = statName;
[(UISwitch *)cell.editingAccessoryView setOn:[self switchValueForIndexPath:indexPath withStatNamed:statName]];
if (tableView.editing) cell.statValue.hidden = YES;
return cell;
}
我試圖重寫setEditing
方法的延遲之後重新加載表數據以允許動畫來完成,但它僅適用有時候
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
// Insert/delete the stat rows depending on editing mode
[self rebuildTableDataAnimated:YES];
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Trying to fix bug that shows part of a UISwitch on screen still even though editing mode is completed
[self.tableView reloadData];
});
}
這裏有一個截屏:
我的第一次嘗試是在執行編輯之後重新加載表格。 – 2013-03-02 14:47:22
@flexaddicted不幸的是,沒有工作 – iwasrobbed 2013-03-02 15:19:04
對不起,我沒有看到它。如何重新加載它像'[tableView setEditing:NO animated:YES]; [tableView reloadData];'?你在後臺執行一些計算嗎? – 2013-03-02 15:28:45