ios - 为什么 UITableView 单元格在滚动时重叠?
<p><p>我有一个大约 100 行的 <code>UITableView</code>。</p>
<p>每个单元格都有选中的图像,但是当我们滚动 <code>UITableView</code> 时,所有单元格都在未选中的单元格中重叠。 </p>
<pre><code>(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"Cell";
static NSString *MyIdentifierAds = @"Cell1";
UITableViewCell *cell ;
if (tableView==self.tblSeachMarketplace) {
if (indexPath.section==0) {
cell = ;
// if(cell== nil)
// {
// cell = [ initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
// }
UILabel* lblTitle = (UILabel *);
UILabel*lblSubheading = (UILabel *);
UIImageView* imgRating = (UIImageView *);
UIImageView* imgLogo = (UIImageView *);
];
];
];
];
];
NSDictionary*row=[init];
cell.contentView.backgroundColor =;
if (allMarketPlaceNewsletters.count>0) {
row=;
NSString *imgUrl=;
if (imgUrl != (id)) {
NSURL *urlTemp = ;
];
}
UIButton *btnLocationRight=(UIButton *);
UIButton *btnLocationPlus=(UIButton *);
if ([ isEqualToString:@"Y"]) {
;
;
cell.contentView.backgroundColor =;
forState:UIControlStateNormal];
;
// ;
//];
}else{
cell.contentView.backgroundColor =;
;
;
forState:UIControlStateNormal];
;
;
// ];
}
NSString *stars= intValue]];
imgRating.image=;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 <code>cellForRowAtIndexPath</code></p> 中添加此代码
<pre><code>NSArray *subviews = [ initWithArray:cell.contentView.subviews];
for (UIView *subview in subviews)
{
if(])
;
else if(])
;
else if(])
;
else if(])
;
else if(])
;
}
;
</code></pre>
<p>希望这会对您有所帮助。在此先感谢您。</p></p>
<p style="font-size: 20px;">关于ios - 为什么 UITableView 单元格在滚动时重叠?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/20118286/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/20118286/
</a>
</p>
页:
[1]