iOS检测用户是否在iPad上

我有一个可以在iPhone和iPod Touch上运行的应用程序,它可以在Retina iPad上运行,但所有其他操作都需要进行一次调整。我需要检测当前的设备是否为iPad。我可以使用什么代码检测用户是否正在使用iPad UIViewController,然后进行相应更改?



忽然笑
浏览 614回答 3
3回答

森栏

在Swift中,您可以使用以下等式确定通用应用程序上的设备类型:UIDevice.current.userInterfaceIdiom == .phone// orUIDevice.current.userInterfaceIdiom == .pad用法如下所示:if UIDevice.current.userInterfaceIdiom == .pad {    // Available Idioms - .pad, .phone, .tv, .carPlay, .unspecified    // Implement your logic here}
打开App,查看更多内容
随时随地看视频慕课网APP