简体   繁体   English

使用自适应布局的iPhone和iPad设备的不同uitableview单元高度

[英]Different uitableview cell height for iPhone and iPad devices using adaptive layout

I am designing universal app for multiple devices. 我正在为多个设备设计通用应用程序。 I want different uitableviewcell height for these devices only using storyboard and constraints or you can say I want to do so using adaptive layout or size classes. 我只希望使用情节提要和约束来为这些设备设置不同的uitableviewcell高度,或者可以说我想使用自适应布局或大小类来做到这一点。 I have searched alot but could not find any solution. 我已经搜索了很多,但找不到任何解决方案。 Please guide me in this regard. 请在这方面指导我。

you could implement the height for cell function and in it check 您可以实现单元格功能的高度并在其中检查

 override func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat {

 if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad)   
  {
    // Ipad
     return 100;
  }
 else 
  {
   // Iphone
     return 50;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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