简体   繁体   English

我如何从XIB转到Storyboard?

[英]How do I go from XIB to Storyboard?

I've been trying a lot of things, to many to list. 我一直在尝试很多事情,以列出更多。 I'm using this code to go from a storyboard view controller to a XIB view controller: 我正在使用以下代码从情节提要视图控制器转到XIB视图控制器:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 2) {
    if (indexPath.row == 1) {
        BLoginViewController *viewController=[[BLoginViewController alloc]initWithNibName:@"BLoginViewController" bundle:nil];

        [self presentViewController:viewController animated:YES completion:nil];
    }

}

[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

The problem is, once the XIB view controller loads, I can't get back to the storyboard! 问题是,一旦加载了XIB视图控制器,我将无法回到情节提要!

I've added a tool bar with a tool bar button on it named "Close". 我添加了一个带有工具栏按钮的工具栏,该工具栏名为“关闭”。 I connected the "Close" button with the XIB's viewcontroller.h file and I added @synthesize closeButton; 我将“关闭”按钮与XIB的viewcontroller.h文件连接在一起,并添加了@synthesize closeButton; to the XIB's viewcontroller.m file, then something like this in the XIB's viewcontroller.m file and linked it to the "Close" tool bar button: 到XIB的viewcontroller.m文件,然后在XIB的viewcontroller.m文件中将其链接到“关闭”工具栏按钮:

- (IBAction)closeButtonPressed:(id)sender { }

I don't know what code to put in the "Close" button to make it go back to the original starting storyboard view controller. 我不知道要在“关闭”按钮中放入什么代码才能使其返回到原始的启动情节提要视图控制器。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Use this code 使用此代码

[self dismissViewControllerAnimated:true completion:nil];

or 要么

use the following if your viewcontroller embedded into navigation controller 如果您的viewcontroller已嵌入导航控制器,请使用以下命令

[self.navigationController popToRootViewControllerAnimated:YES];

To remove BAppTabBarController from window Try this in BAppTabBarController.m file 从窗口中删除BAppTabBarControllerBAppTabBarController.m文件中尝试此操作

@implementation BAppTabBarController

    - (IBAction)closeButtonPressed:(id)sender {
     [self dismissViewControllerAnimated:true completion:nil];

    }

@end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM