English 中文(简体)
iPhone自定义UITableViewCell重新加载
原标题:IPhone custom UITableViewCell Reloading

currently I m struggling with this problem: I got a UITableViewController that displays a tableView with different custom cells.

One custom cell displays a number (by a label). If you click on this cell, the navigationController moves to a UIPicker where the user can select the number to be displayes. If the user moves back, the cell should display the updated value.

Problem: I managed to reload the cells by calling

- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  [self.tableView reloadData];
}

在UITableViewController中。

This works only, if I don t use dequeueReusableCellWithIdentifier for the cell (tables won t show updates otherwise). But in this case, memory usage grows and grows... In addition, the program crashes after about 15 movements to pickerView and back - I think because the cell that should be reloaded is already released.

How can I update a reusable custom cell every time the view appears ? What is the best solution ?

我认为不应该使用保留细胞。

问题回答

一种常见的方法是,如果仅更改一个单元格,则避免重新加载整个表格。

在这种情况下,只需获取要“刷新”的UITableViewCell的引用,并在主线程上调用 [self setNeedsDisplay] 来触发其刷新(将调用 drawRect 来触发其绘制)。

你在 NIB 中设置了适当的 ID 吗?它必须与你在调用 dequeueReusableCellWithIdentifier: 时使用的相同。

请看第三步这里





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。