Rotate a custom UITableViewCell

前端 未结 6 593
有刺的猬
有刺的猬 2020-12-29 14:36

I have a custom UITableViewCell which contains several UIButtons. Each button\'s frame position is relative to the cell width. I set autoresizingMask=UIViewAutoresizingFlexi

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 15:20

    I had a similar problem and this post helped me. In my case I have a custom class declared in a separate file, and in this file I have the following code in layoutSubviews:

    //PORTRAIT CELL
    if ([UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeLeft && 
        [UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeRight)
    {
        //build the custom content views for portrait mode here
    }
    else
    {
        //build the custom content views for landscape mode here
    }
    

    Then in my view controller I just implement willAnimateRotationToInterfaceOrientation: and send the reloadData message to my table view.

    With this I don't have to touch the cellForRow method.

提交回复
热议问题