Ios 视图未加载,但未加载viewDidLoad
我有两个视图控制器:Ios 视图未加载,但未加载viewDidLoad,ios,xcode-storyboard,Ios,Xcode Storyboard,我有两个视图控制器:BSViewController和BSotherViewControllerBSViewController上有一个按钮,可连接到BSotherViewController。这部分工作得很好,当我在模拟器上运行时,我可以看到一个VC,然后是“另一个”VC。但是我有一个NSLog(@“other”)。类似的NSLog(@“其他”)。我怀疑问题在于缺少一个iAction,但我不知道它应该放在哪里,以及它应该如何在故事板中链接 BSViewController.h #import
BSViewController
和BSotherViewController
BSViewController
上有一个按钮,可连接到BSotherViewController
。这部分工作得很好,当我在模拟器上运行时,我可以看到一个VC,然后是“另一个”VC。但是我有一个NSLog(@“other”)控制台中未显示的BSotherViewController
的-viewDidLoad
中的code>。类似的NSLog(@“其他”)控制台中显示的BSViewController
的-viewDidLoad
中的code>。我怀疑问题在于缺少一个iAction
,但我不知道它应该放在哪里,以及它应该如何在故事板中链接
BSViewController.h
#import <UIKit/UIKit.h>
@interface BSViewController : UIViewController
@property (nonatomic) NSInteger number;
@end
#import <UIKit/UIKit.h>
@interface BSotherViewController : UIViewController
@property (nonatomic) NSInteger anumber;
@end
b其他视图控制器
#import <UIKit/UIKit.h>
@interface BSViewController : UIViewController
@property (nonatomic) NSInteger number;
@end
#import <UIKit/UIKit.h>
@interface BSotherViewController : UIViewController
@property (nonatomic) NSInteger anumber;
@end
在情节提要中,第二个视图控制器是否设置为b其他视图控制器
?您可以将鼠标悬停在情节提要中的“视图控制器”图标上进行验证
如果不是,则单击它并转到identity controller并键入它
在情节提要中,第二个视图控制器是否设置为b其他视图控制器
?您可以将鼠标悬停在情节提要中的“视图控制器”图标上进行验证
如果不是,则单击它并转到identity controller并键入它
嘿,Zero,一个简单的解决方案是只使用ViewWillDisplay或ViewDidDisplay,并不需要每次调用ViewDidLoad。。。它可能会在BSViewController中调用,因为当您将应用程序启动到模拟器时,它会以全新的方式运行,因此需要加载视图。有时使用模态分段和一些不一定要调用viewDidLoad的东西…嘿,Zero,一个简单的解决方案是只使用ViewWillExisten或ViewDidExister,并不需要每次调用viewDidLoad。。。它可能会在BSViewController中调用,因为当您将应用程序启动到模拟器时,它会以全新的方式运行,因此需要加载视图。有时使用模态分段和一些不一定要调用viewDidLoad的东西……现在我可以解决真正的问题:为什么other number
0而不是25?诊断很好,罗杰斯先生。这是因为BSViewController
的视图尚未加载。25的初始化发生在viewDidLoad
中。您可以在登录anumber
之前,通过记录视图控制器的视图
属性来验证它。现在我可以解决真正的问题:为什么其他数字
是0而不是25?诊断很好,罗杰斯先生。这是因为BSViewController
的视图尚未加载。25的初始化发生在viewDidLoad
中。您可以在登录anumber
之前,通过记录视图控制器的视图
属性来验证它。