简体   繁体   中英

setting x position to the UITablecell in UITableView

I have UITableview in that i'm going to load custom table cells.By default cell co-ordinates at zero position but i need place it at my required position (ie,30,0) i have written code like this::

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSLog(@"tableView willDisplayCell");
     CGRect frame = cell.frame;
    frame.origin.x = 30;
    frame.size.width = 250;
    cell.frame = frame;  
}

for first time Table cell is not loading at mentioned position after reloading it is working fine thanks in advance

Don't change the frame of the cell. Instead, make the cell background whatever colour your overall background is (maybe transparent) and add a view of your desired size as a subview of the cell contentView . Then add all of your content to this view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM