使用情节提要的某些选项卡需要IOS登录

使用情节提要的某些选项卡需要IOS登录,ios,iphone,objective-c,login,storyboard,Ios,Iphone,Objective C,Login,Storyboard,我的问题基于以下问题,但我的情况正好相反 我想为用户提供一些专用选项卡,仅在需要登录时使用,我的故事板如下: 下面是我在自定义tabBarController中的代码 @interface PNTabBarController () @end @implementation PNTabBarController - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSUInteger in

我的问题基于以下问题,但我的情况正好相反

我想为用户提供一些专用选项卡,仅在需要登录时使用,我的故事板如下:

下面是我在自定义tabBarController中的代码

@interface PNTabBarController ()

@end

@implementation PNTabBarController

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    NSUInteger indexOfTab = [tabBar.items indexOfObject:item];
    NSLog(@"%lu", (unsigned long)indexOfTab);
    if (indexOfTab == 2 || indexOfTab == 3) {
        PFUser *currentUser = [PFUser currentUser];
        NSLog(@"%@", currentUser.username);
        if(currentUser == nil){          
            PNLoginViewController *obj = [[PNLoginViewController alloc]init];
            [self presentViewController:obj animated:YES completion:NULL];
        }
        else{
            NSLog(@"%@", currentUser.username);
        }
    }
}

但当我单击2或3选项卡时,会出现一个黑屏。实现这一点的正确方法是什么?

if(currentUser==nil){NSLog(@“%@”,currentUser.username)
…逻辑问题?是的,谢谢你提醒我粗心的错误。尝试了
initWithNibName
PNLoginViewController
?需要澄清:
PNLoginViewController
是否没有出现,而是显示了黑色屏幕?@ShivanRaptor是的PNLoginViewController并不是只显示黑色屏幕