我正在为我的网络浏览器制作一个书签页面,问题是每次我添加一个新对象时,我都必须设置属性,因为我创建了一个自定义单元格(我必须设置两个标签的文本),所以我需要一种方法仅编辑新添加的对象...我熟悉索引,但无法提出任何解决此问题的方法...例如,当我将第一页添加为书签时,它很好,但是一旦我将 2 页添加为书签,则 2细胞是完全相同的......有什么想法吗?
这是我的代码:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell*)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil];
cell = (CustomCell *) [nib objectAtIndex:0];
}
// Set up the cell...
NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
NSString *currentURL = webView.request.URL.absoluteString;
cell.websiteTitle.text = theTitle;
cell.websiteURL.text = currentURL;
universalURL = currentURL;
return cell;
}
设置单元格时,我需要指向最新的单元格!
先感谢您!