第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是否可以刷新UITableView中的單個UITableViewCell?

是否可以刷新UITableView中的單個UITableViewCell?

侃侃無極 2019-11-06 10:17:06
我有一個UITableView使用UITableViewCells 的自定義。每個UITableViewCell按鈕都有2個按鈕。單擊這些按鈕將更改UIImageView單元格中的圖像。是否可以分別刷新每個單元以顯示新圖像?任何幫助表示贊賞。
查看完整描述

3 回答

?
楊魅力

TA貢獻1811條經(jīng)驗 獲得超6個贊

有了單元格的indexPath后,您可以執(zhí)行以下操作:


[self.tableView beginUpdates];

[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPathOfYourCell, nil] withRowAnimation:UITableViewRowAnimationNone];

[self.tableView endUpdates]; 

在Xcode 4.6和更高版本中:


[self.tableView beginUpdates];

[self.tableView reloadRowsAtIndexPaths:@[indexPathOfYourCell] withRowAnimation:UITableViewRowAnimationNone];

[self.tableView endUpdates]; 

當(dāng)然,您可以設(shè)置任何喜歡的動畫效果。


查看完整回答
反對 回復(fù) 2019-11-06
?
守著星空守著你

TA貢獻1799條經(jīng)驗 獲得超8個贊

我嘗試僅致電-[UITableView cellForRowAtIndexPath:],但是沒有用。但是,以下示例對我有用。我alloc和release該NSArray用于緊密內(nèi)存管理。


- (void)reloadRow0Section0 {

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

    NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];

    [self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];

    [indexPaths release];

}


查看完整回答
反對 回復(fù) 2019-11-06
?
吃雞游戲

TA貢獻1829條經(jīng)驗 獲得超7個贊

reloadRowsAtIndexPaths:很好,但是仍然會迫使UITableViewDelegate方法觸發(fā)。


我能想到的最簡單的方法是:


UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];

[self configureCell:cell forIndexPath:indexPath];

這是重要的調(diào)用你configureCell:的主線程中執(zhí)行,如在非UI線程它不會工作(同樣的故事reloadData/ reloadRowsAtIndexPaths:)。有時添加以下內(nèi)容可能會有所幫助:


dispatch_async(dispatch_get_main_queue(), ^

{

    [self configureCell:cell forIndexPath:indexPath];

});

還有必要避免在當(dāng)前可見視圖之外進行的工作:


BOOL cellIsVisible = [[self.tableView indexPathsForVisibleRows] indexOfObject:indexPath] != NSNotFound;

if (cellIsVisible)

{

    ....

}


查看完整回答
反對 回復(fù) 2019-11-06
  • 3 回答
  • 0 關(guān)注
  • 749 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號