Universal storyboard UITableview row Height

2019-09-03 09:02发布

问题:

Using Storyboard sizeClasses i want to define the different TableView Row Height

  • Using UITableView Row Height Automatic based on screen height (Specially in iPad)
  • Using Static TableView i Also want to achieve the Dynamic Row so that we can utilize the screen Height

It might be possible that the Question is very old and may be its duplicate also but i have searched and not getting proper result so its better i should ask this again might be something new in Xcode 7 with iOS 9 so guys anyone have any good resource which fullfill my requirement please share it, Thanks is advanced

回答1:

You can set the row height in heightForRowAtIndexPath: delegate method of UITalbeView.

You can get the trait-collection details and then use it to identify the current size class.

NSInteger horizontalClass = self.traitCollection.horizontalSizeClass;
NSInteger verticalCass = self.traitCollection.verticalSizeClass;

switch (horizontalClass) {
    case UIUserInterfaceSizeClassCompact :
        // horizontal is compact class.. do stuff...
        break;
    case UIUserInterfaceSizeClassRegular :
        // horizontal is regular class.. do stuff...
        break;
    default :
        // horizontal is unknown..
        break;
}

Then you can calculate or set a predefined row height as per device height.