简体   繁体   English

故事板更改未在iPhone Simulator中更新

[英]Storyboard changes not updating in iPhone Simulator

It is a few days that I have this problem and I have not managed to solve it.. 过了几天,我遇到了这个问题,但没有设法解决。

I completed a storyboard for iPhone 5, now I've created a new storyboard to iPhone 6, I copied the various ViewController from the storyboard for iPhone 5 and I made some changes. 我完成了iPhone 5的情节提要,现在我为iPhone 6创建了一个新的情节提要,从iPhone 5的情节提要中复制了各种ViewController,并进行了一些更改。

Now i run my app on iPhone 6 Simulator and no change I've made is visible! 现在,我在iPhone 6 Simulator上运行我的应用程序,并且看不到我所做的任何更改

I attach some screenshot: 我附上一些截图:

在此处输入图片说明

for example I change the background color of UICollectionView in Blue, but this is the result: 例如,我将UICollectionView的背景颜色更改为蓝色,但这是结果:

在此处输入图片说明

I tried to Reset Simulator, delete DerivedData folder, restart Xcode, delete Storyboard 6 and re-add, I do not know what else to try, I never encountered this kind of problem 我尝试重置模拟器,删除DerivedData文件夹,重新启动Xcode,删除Storyboard 6并重新添加,但我不知道还有什么尝试,我从未遇到过此类问题

I tried with Xcode 6.4, now I upgraded to Xcode 7 but the problem there is still... 我尝试使用Xcode 6.4,现在我已升级到Xcode 7,但是问题仍然存在...

EDIT : 编辑

in AppDelegate I grab the right storyboard in this way: 在AppDelegate中,我以这种方式获取正确的故事板:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

 _storyboard = [self grabStoryboard];

 //login-registrati view
lvc = (LoginController *)[_storyboard instantiateViewControllerWithIdentifier:@"login"];

tabbarController = (UITabBarController *)self.window.rootViewController;

if (isLogged == YES) {

    self.window.rootViewController = tabbarController;

}
else {

    self.window.rootViewController = lvc;
}

[self.window makeKeyAndVisible];

...
}

- (UIStoryboard *)grabStoryboard {

int screenHeight = [UIScreen mainScreen].bounds.size.height;
UIStoryboard *storyboard;

switch (screenHeight) {

        // iPhone 4s
    case 480:
        storyboard = [UIStoryboard storyboardWithName:@"Main3.5" bundle:nil];
        break;

        // iPhone 5s
    case 568:
        storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        break;

        // iPhone 6
    case 667:
        storyboard = [UIStoryboard storyboardWithName:@"Main6" bundle:nil];
        break;

        // iPhone 6 Plus
    case 736:
        storyboard = [UIStoryboard storyboardWithName:@"Main6+" bundle:nil];
        break;
}

return storyboard;
}

I know that the Simulator get the right storyboard is that in some ViewController I can see the changes, but if I change the ViewController related to UITabbarController that is the root view controller, there isn't changes on simulator... 我知道模拟器获得正确的故事板是在某些ViewController中我可以看到更改,但是如果更改与作为根视图控制器的UITabbarController相关的ViewController,则模拟器上没有任何更改...

Try to create a property for UIViewController: 尝试为UIViewController创建一个属性:

@property (strong, nonatomic) UIViewController *initialViewController;

and do this after you get the new storyboard reference: 在获得新的故事板参考之后执行以下操作:

_storyboard = [self grabStoryboard];
self.initialViewController = [_storyboard instantiateInitialViewController];

and then change your rootview 然后更改您的rootview

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.initialViewController;
[self.window makeKeyAndVisible];

Edit: 编辑:

I even tried your way. 我什至试过了。 And it worked too.Please make sure you have set the view controller identifier in xcode and it matches to "login" 而且它也起作用。请确保您已在xcode中设置了视图控制器标识符,并且该标识符与“登录”匹配

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
lvc = (LoginController *)[_storyboard instantiateViewControllerWithIdentifier:@"login"];
 self.window.rootViewController = lvc;
 [self.window makeKeyAndVisible];

From the documentation: 从文档中:

instantiateInitialViewController instantiateInitialViewController

Instantiates and returns the initial view controller in the view controller graph. 实例化并返回视图控制器图中的初始视图控制器。

Typically, you use this method only when transitioning to the initial view controller in a different storyboard file. 通常,仅在转换到其他故事板文件中的初始视图控制器时才使用此方法。

Edit Ilario: 编辑Ilario:

I accepted your answer because it put me in the right direction, I solved changing in this way: 我接受了您的回答,因为它使我朝着正确的方向前进,我解决了这种变化:

tabbarController = (UITabbarController *)[_storyboard instantiateInitialViewController];

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

相关问题 情节提要更改未在模拟器/ iPhone中更新 - Storyboard changes not updating in simulator/iphone Swift XCode-情节提要中的更改未反映在iPhone模拟器中 - Swift XCode - Changes in storyboard aren't being reflected in the iPhone simulator IBInspectable 不在情节提要中更新,但在模拟器上工作 - IBInspectable not updating in storyboard but works on simulator iPhone Pluses和X中的故事板和模拟器的视图不同 - Views differ in storyboard and Simulator in iphone Pluses and X Xcode故事板更改未在设备或模拟器上显示 - Xcode storyboard changes not showing on device or simulator 忘了添加IPad故事板,现在Simulator总是运行IPhone故事板 - Forgot to add IPad storyboard and now Simulator is always running IPhone storyboard iOS:自动版面配置问题。 模拟器的结果随着情节提要的变化而变化 - iOS: A Issue with Auto Layout. Simulator Result Changes As Storyboard Changes 为什么我的按钮不在 iphone 模拟器中显示,但在 storyboard 中显示 - Why is my button not displaying in the iphone simulator but showing in storyboard 在iphone5(7.1)模拟器上,在StoryBoard上创建的UIBarButtonItem没有调用IBAction方法 - On iphone5 (7.1) simulator, UIBarButtonItem created on StoryBoard not calling IBAction method iPhone视网膜4英寸模拟器,情节提要设置为3.5英寸 - iPhone retina 4-inch Simulator with Storyboard set to 3.5 inch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM