如何在AppDelegate中显示UIViewControllers UIView?

时间:2014-08-09 14:52:37

标签: ios uiview uiviewcontroller appdelegate

我正在为我的应用制作一些小密码,我喜欢在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;的AppDelegate方法中提供它。

我在Storyboard中创建了PasscodeViewController,因为它更容易,现在我尝试呈现UIView。 PasscodeViewController应该是透明的,因为我喜欢模糊它背后的应用UIWindow。这就是我试过的:

PasscodeViewController *pcvc = [[UIStoryboard storyboardWithName:[self isiPad]?@"Main-iPad":@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"PasscodeView"];
    [pcvc loadView];
    pcvc.view.backgroundColor = [UIColor clearColor];
    [self.window addSubview:pcvc.view];
    [self.window bringSubviewToFront:pcvc.view];

pcvc永远不会出现。

是否有人知道为什么或有更好的方式来展示此UIViewController或其UIView

谢谢大卫

修改 这是[self isiPad];

-(BOOL)isiPad {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return YES;
    } else {
        return NO;
    }
}

0 个答案:

没有答案