为了账号安全,请及时绑定邮箱和手机立即绑定

iOS检测用户是否在iPad上

iOS检测用户是否在iPad上

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

3 回答

?
森栏

TA贡献1810条经验 获得超5个赞

在Swift中,您可以使用以下等式确定通用应用程序上的设备类型:


UIDevice.current.userInterfaceIdiom == .phone

// or

UIDevice.current.userInterfaceIdiom == .pad

用法如下所示:


if UIDevice.current.userInterfaceIdiom == .pad {

    // Available Idioms - .pad, .phone, .tv, .carPlay, .unspecified

    // Implement your logic here

}


查看完整回答
反对 回复 2019-12-09
  • 3 回答
  • 0 关注
  • 609 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信