首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >茜素取向info.plist

茜素取向info.plist
EN

Stack Overflow用户
提问于 2019-06-28 18:25:10
回答 1查看 238关注 0票数 0

我有一个问题,在ISO设置设备的方向。对于iPhone,我想把它锁定到只有肖像模式,但对于iPad,我希望用户能够使用肖像,景观左右。该设置将不会为每个设备保存。

我需要换一种方式吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-28 18:33:47

使用文本编辑器打开您的info.plist。应该有两个方向部分,您可以定义每个成语的方向,如下所示

代码语言:javascript
复制
<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

如果这不能正常工作,您也可以在代码中解决这个问题。在AppDelegate.cs中,尝试重写GetSupportedInterfaceOrientations。

代码语言:javascript
复制
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations
(
  UIApplication application, 
  [Transient] UIWindow forWindow
)
{
  // You will need to figure out how to determine what kind of device you're on. I suggest Xamarin.Essentials, they probably have a service for that.
  if (iPhone)
  {
    return UIInterfaceOrientationMask.Portrait;
  }

  if (iPad)
  {
    return UIInterfaceOrientationMask.AllButUpsideDown;
  }

  return UIInterfaceOrientationMask.All;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56811657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档