ios - UITableView下拉后cell位置改变
PHP中文网
PHP中文网 2017-04-18 09:05:40
0
3
321

大家好,我是一iOS新手,目前遇到一个很奇怪的问题:
我写了一个小程序想学下自定义UITableViewCell,自定义的contentView中只有一个ImageView,然后一开始显示正常,但是当我下拉后,cell就改变了位置,这是为什么

前两个图是正常初始化出来的,后一个是下拉后刷新出来的。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HWHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HWHomePageCell"];
    if (cell == nil)
    {
        cell = [HWHomePageCell homePageCell];
    }
        cell.imageView.image = [UIImage imageNamed:@"Test"];
    
    return cell;
}

我觉得是代码重用这里的问题,但是我尝试了各种设置,都没有用。。。求大神赐教

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
黄舟

cell = [HWHomePageCell homePageCell]
Have you written the correct ID in this initialization method honmePageCell?
Also try writing the ID of the cell on the storyBoard

Ty80

Try writing the coordinates of a custom cell in the layoutSubView method

Ty80

Finally, I deleted the conditional judgment of if (cell == nil), and the result was just fine.
Sincere thanks to everyone above for your enthusiastic help!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template