我有两个视图控制器:BSViewController
和BSotherViewController
。 BSViewController
上有一个按钮,它位于BSotherViewController
。那部分工作正常,当我在模拟器上运行时,我可以看到一个VC,然后是“其他”VC。但我在NSLog(@"other");
的{{1}}中有BSotherViewController
,但未在控制台中显示。 -viewDidLoad
的{{1}}中的NSLog(@"other");
类似于控制台中显示的BSViewController
。我怀疑问题是缺少-viewDidLoad
,但我无法确定它应该去哪里以及它应该如何在故事板中链接。
BSViewController.h
IBAction
BSViewController.m
#import <UIKit/UIKit.h>
@interface BSViewController : UIViewController
@property (nonatomic) NSInteger number;
@end
BSotherViewController.h
#import "BSViewController.h"
@interface BSViewController ()
@end
@implementation BSViewController
@synthesize number;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.number = 25;
NSLog(@"number: %d", self.number);
}
@end
BSotherViewController.m
#import <UIKit/UIKit.h>
@interface BSotherViewController : UIViewController
@property (nonatomic) NSInteger anumber;
@end
答案 0 :(得分:1)
在故事板中,第二个视图控制器设置为BSotherViewController
?您可以将鼠标悬停在故事板中的视图控制器图标上进行验证。
如果不是,则单击它并转到身份控制器并输入。