Positioning the imageView of a UITableViewCell

前端 未结 6 1274
走了就别回头了
走了就别回头了 2020-12-16 13:53

In every UITableViewCell of a UITableView I\'m placing an image in its imageView. However, if I increase the height of a cell using tableView:heightForRowAtIndexPath: to acc

6条回答
  •  醉梦人生
    2020-12-16 14:43

    You need to subclass UITableViewCell and override layoutSubviews, as follows:

    - (void) layoutSubviews
    {   
        [super layoutSubviews];
    
        self.imageView.frame = CGRectMake( 10, 10, 50, 50 ); // your positioning here
    }
    

    In your cellForRowAtIndexPath: method, be sure to return an instance of your new cell type.

提交回复
热议问题