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 和 iPad 上运行良好。但是,滚动视图设置为 iPad 尺寸。因此,当我在 iPhone 上运行该应用程序时,仍然为 iPad 设置了滚动视图。
有什么办法可以改变吗?
你可以使用这个:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { [myScrollView setFrame:CGRectMake(0, 0, 320, 480)]; }else{ [myScrollView setFrame:CGRectMake(0, 0, 768, 1024)]; }
当然,您还必须调整滚动视图的内容大小。