Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的代码中为 iPhone 应用程序绘制了一个UIView(ie )。UIButton
UIView
UIButton
现在我想开发一个iPad版本,但是由于iPhone和iPad的屏幕尺寸不同,所以UIView应该有不同的尺寸。我该怎么做才能以编程方式处理视图?
对于通用 iOS 应用程序,询问您正在服务的设备并相应地绘制您的视图
所以在你的视图控制器中使用::
-(void)viewWillAppear:(BOOL)animated { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { //draw accordingly to your layout for iPad } else { //iphone layout } }