最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

关于iPad程序如何强制横屏

来源:动视网 责编:小OO 时间:2024-12-11 07:58:35
文档

关于iPad程序如何强制横屏

UISupportedInterfaceOrientations~ipad。UIInterfaceOrientationLandscapeLeft。UIInterfaceOrientationLandscapeRight。然而,尽管按照上述步骤进行设置,部署测试后却并未生效。另一种方法是在每个nib文件中通过IB设置orientation为landscape,但这种方法同样也不生效。为了避免重复劳动,可以重载shouldAutorotateToInterfaceOrientation:方法。具体实现如下:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {。
推荐度:
导读UISupportedInterfaceOrientations~ipad。UIInterfaceOrientationLandscapeLeft。UIInterfaceOrientationLandscapeRight。然而,尽管按照上述步骤进行设置,部署测试后却并未生效。另一种方法是在每个nib文件中通过IB设置orientation为landscape,但这种方法同样也不生效。为了避免重复劳动,可以重载shouldAutorotateToInterfaceOrientation:方法。具体实现如下:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {。


在开发iPad程序时,强制应用横屏是一个常见的需求。开发者通常会尝试通过在XCode中设置“iPad Deployment info”,仅选择横屏左和横屏右的方法。然而,这种方法实质上是在xxx_info.plist项目配置文件中添加如下信息:
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
然而,尽管按照上述步骤进行设置,部署测试后却并未生效。

另一种方法是在每个nib文件中通过IB设置orientation为landscape,但这种方法同样也不生效。为了避免重复劳动,可以重载shouldAutorotateToInterfaceOrientation:方法。具体实现如下:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return ((interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (interfaceOrientation == UIDeviceOrientationLandscapeRight));
}

如果第一种方法能够生效,那将是最理想的解决方案。然而,通过重载shouldAutorotateToInterfaceOrientation:方法来实现横屏需求,虽然可以完全满足需求,但在实际开发中却显得较为繁琐,需要在每个controller中都重载该方法。当然,也可以通过扩展UIViewController的方式来简化这一过程。

不过,这种解决方案还是显得不够直接。因此,开发者们一直在寻找更简便的方式,以期在SDK本身中找到一种更简洁的支持方法。如果存在更为简捷的解决方案,那将是开发者们的共同期待。

文档

关于iPad程序如何强制横屏

UISupportedInterfaceOrientations~ipad。UIInterfaceOrientationLandscapeLeft。UIInterfaceOrientationLandscapeRight。然而,尽管按照上述步骤进行设置,部署测试后却并未生效。另一种方法是在每个nib文件中通过IB设置orientation为landscape,但这种方法同样也不生效。为了避免重复劳动,可以重载shouldAutorotateToInterfaceOrientation:方法。具体实现如下:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {。
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top