您当前的位置: 首页 >  ios

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

讲解如何禁止iOS屏幕自动旋转

鱼儿-1226 发布时间:2020-09-01 10:25:54 ,浏览量:0

讲解如何禁止iOS屏幕自动旋转

在重力感应游戏中,经常会造成屏幕自动旋转的情况,这样会造成屏幕倒置,对操作造成不便,禁止重力感应的方法是:

在“项目/ios/RootViewController.mm”中,找到如下函数

// Override to allow orientations other than the default portrait orientation.

– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

// return UIInterfaceOrientationIsPortrait( interfaceOrientation );

#if defined(DISABLE_AUTO_ROTATE_ON_IPAD) && DISABLE_AUTO_ROTATE_ON_IPAD != 0

return interfaceOrientation == UIInterfaceOrientationPortrait;

#else

return YES;

#endif

} else {

return interfaceOrientation == UIInterfaceOrientationPortrait;

}

}

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.3313s