在 iPad 和 iPhone 之间更改 Table 视图的行高大小
Change Row Height size of Table View between iPad and iPhone
我知道考虑大小 class,但在这里我不知道该怎么做,在我的菜单上我不想在 iPad 上设置比 iPhone.
这里我可以设置行高:
但我不知道如何在这里使用大小 class 来在不同设备之间设置不同的高度。
如果可以选择在代码中执行此操作,您可以在 viewDidLoad
:
中执行类似的操作
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
tableView.rowHeight = 100;
}
else {
tableView.rowHeight = 44;
}
它应该适用于 iOS 3.2 及更高版本,所以基本上任何你可以实际定位的东西。
在Swift中使用:
if(UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad){
return 500
}
else {
return 200
}
我知道考虑大小 class,但在这里我不知道该怎么做,在我的菜单上我不想在 iPad 上设置比 iPhone.
这里我可以设置行高:
但我不知道如何在这里使用大小 class 来在不同设备之间设置不同的高度。
如果可以选择在代码中执行此操作,您可以在 viewDidLoad
:
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
tableView.rowHeight = 100;
}
else {
tableView.rowHeight = 44;
}
它应该适用于 iOS 3.2 及更高版本,所以基本上任何你可以实际定位的东西。
在Swift中使用:
if(UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad){
return 500
}
else {
return 200
}