everyone,I am a beginner in iOS development.
Now I face a problem:I wrote a small program to learn custom UITableViewCell. It just can work well at the beginning. When I slide the view, it will change. I feel really confuse.
And the ContentView only has one view which is UIImageView.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HWHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HWHomePageCell"];
if (cell == nil)
{
cell = [HWHomePageCell homePageCell];
}
cell.imageView.image = [UIImage imageNamed:@"XD"];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HWHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HWHomePageCell"];
cell = [HWHomePageCell homePageCell];
cell.imageView.image = [UIImage imageNamed:@"XD"];
return cell;
}
When you use custom cell then no need to check whether cell is nil or not. so please remove this condition and implement it.