iphone - 滚动表格 View 时自定义标签值消失
<p><p>我是 iPhone 新手。当我滚动表格 View 时,我的 <code>cutomcell 标签</code> 值正在消失。 </p>
<p>当我点击那个单元格时它再次出现。</p>
<p>谁能帮帮我?</p>
<p>提前致谢。 </p>
<pre><code>//table view in view controller created in xib
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListOfProductsCell";
ListOfProductsCell *cell = (ListOfProductsCell *);
if (cell==nil) {
NSArray *nib =[ loadNibNamed:@"ListOfProductsCell" owner:self options:nil];
cell = ;
productItemDit=;
NSString *offerStr= floatValue]];
NSString *fullCostStr=[ stringByAppendingString:offerStr];
NSLog(@"%@",fullCostStr);
cell.itemCostLbl.text=fullCostStr;
} else {
cell.itemStepper = (UIStepper *) ;
cell.itemAddedLbl =(UILabel*);
}
if (tableView == self.searchDisplayProduct.searchResultsTableView) {
searchProductItemDit=;
NSLog(@"searchdit:%@",searchProductItemDit);
cell.itemNameLbl.text= ;
self.searchDisplayProduct.searchResultsTableView.separatorColor=;
} else {
productItemDit=;
NSLog(@"dit:%@",productItemDit);
cell.itemNameLbl.text=;
}
cell.itemAddedLbl.text = [ initWithFormat:@"%d",itemCount];
cell.itemImg.image = ;
return cell;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这样解决</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListOfProductsCell";
ListOfProductsCell *cell = (ListOfProductsCell *);
if (cell==nil) {
NSArray *nib =[ loadNibNamed:@"ListOfProductsCell" owner:self options:nil];
cell = ;
} else {
cell.itemStepper = (UIStepper *) ;
cell.itemAddedLbl =(UILabel*);
}
if (tableView == self.searchDisplayProduct.searchResultsTableView) {
cell.itemNameLbl.text= [ objectForKey:@"name"];
} else {
cell.itemNameLbl.text=[ objectForKey:@"name"];
}
cell.itemCostLbl.text= objectForKey:@"offer"] floatValue]];
cell.itemAddedLbl.text = [ initWithFormat:@"%d",itemCount];
cell.itemImg.image = ;
return cell;
}
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 滚动表格 View 时自定义标签值消失,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/17316026/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/17316026/
</a>
</p>
页:
[1]