自定义UIViewController IOS4.3
Posted
技术标签:
【中文标题】自定义UIViewController IOS4.3【英文标题】:Custom UIViewController IOS4.3 【发布时间】:2012-08-20 11:01:26 【问题描述】:我有静态库和我的自定义视图控制器(f.e mainVC)。 我的静态库将在一些第三方应用程序中构建。
我必须在第三个应用启动后立即显示 mainVC.view。 我愿意:
[window addSubView:mainVC.view];
但是我怎样才能使我的 mainVC 处于活动状态?这意味着我必须在
中否认横向- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
在这种情况下,这个方法永远不会调用。
我也试过手动调用
[self.mainVC viewWillAppear:NO];
但还是失败了。
也许我应该使用
-(void)presentModalViewController:animated
但它已被弃用。而且我必须支持ios 4.3
【问题讨论】:
【参考方案1】:您可能希望在调用该方法之前检查该类是否允许响应该方法。
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
[self presentViewController:viewController animated:YES];
else
//some other methods
这样您可以使用已弃用的方法来支持 IOS 4.3,并为更高的 IOS 版本使用另一种解决方案
【讨论】:
正确的方法是使用if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) [self presentViewController:viewController animated:animated completion:completionBlock]; else ...
注:对4.3的方法不太了解,所以抄自他自己的问题方法。如果您想要向后兼容,这个想法保持不变
其实这不是我所需要的。我必须像弹出窗口一样显示 mainVC.view(与 FBDialog 一样),如果我以模态方式呈现 mainVC 并设置 mainVC.view 边距......它在我的 mainVC.view 周围有黑色区域以上是关于自定义UIViewController IOS4.3的主要内容,如果未能解决你的问题,请参考以下文章
iPhone IOS5 Storyboard,如何加载带有自定义 .xib 文件的 UIViewController?
如何在通用 UIViewController 之后设置自定义 UIViewController?
关闭一个自定义弹出窗口UIViewController并立即显示另一个自定义弹出窗口UIViewController -SWIFT