【问题标题】:Storyboard UITabBarController故事板UITabBarController
【发布时间】:2012-01-29 17:23:10
【问题描述】:

我正在尝试使用从登录屏幕开始并在用户触摸登录按钮后使用情节提要构建 iphone 应用程序,它应该使用身份验证方法对其进行检查。但是,我无法直接将登录按钮链接到 UITabBarController,因为当用户触摸该按钮时,它会直接进入选项卡栏页面而不检查登录方法。我还尝试创建从 UITabBarController 扩展的 mytabBar 类,并将自定义类中的 UITabBarController 设置为情节提要中的 mytabBar。然后我放入了我的登录视图控制器类;

#import "tabBar.h" 
- (IBAction)loginCheck:(id)sender{

    tabBar *tabbar = [[tabBar alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:tabbar animated:YES];
}

但它仍然无法正常工作。

【问题讨论】:

  • 我的意思是它可以工作,但它会创建新的 UITabBarController,它不会转到我在 xcode 界面生成器中创建的标签栏。

标签: iphone objective-c uitabbarcontroller storyboard


【解决方案1】:

tabBar 是什么类型?此方法中没有check。也许可以:

//...
NSLog(@"Log");
//...

...在方法中确保它被调用。

每当您使用UIStoryboard 时,您都在做类似的事情,而不是初始化tabBar 的新实例:

- (void)showModalAssistantViewController
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //Put your right Storyboard Name here
tabBar *viewController = [storyboard instantiateViewControllerWithIdentifier:@"TabBarController"]; //Put your right identifier here
[viewController setModalPresentationStyle:UIModalPresentationFullScreen];
[viewController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navigationController presentModalViewController:viewController animated:YES];
}

...标识符可以在 IB 的ViewController's Inspector-Tab 中找到。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 2016-01-15
    • 2018-02-01
    • 2012-06-18
    • 2014-05-16
    • 1970-01-01
    • 2013-10-14
    相关资源
    最近更新 更多