![](/img/trans.png)
[英]UITableViewCell disclosure indicator inheriting UIButton's Appearance
[英]UITableViewCell disclosure indicator disappears on scrolling
我有一個自定義 tableViewCell,其中一些子視圖定義在故事板的原型單元格中。 在故事板中,我將 Accessory 設置為 Disclosure Indicator,但是當滾動時(當單元格被重用時),指示器消失了。
我試圖在代碼中設置它:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
它也沒有奏效。 但我找到了一個有效的解決方案,一個非常奇怪的解決方案:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
我不知道為什么這可以解決任何問題,但它對我有用。 誰能告訴我為什么或者是否有其他問題/修復?
更新:
我如何獲得可重復使用的單元格:
ActivityWeekCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
我也試過:
ActivityWeekCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
if (cell == nil) {
cell = [[ActivityWeekCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
嘗試使用此變體:
ActivityWeekCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
if (cell == nil) {
cell = [[ActivityWeekCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.