我有两个视图控制器:BSViewController
和BSotherViewController
. BSViewController
有一个按钮,它是 segues to BSotherViewController
。那部分工作正常,当我在模拟器上运行时,我可以看到一个 VC,然后是“另一个”VC。但是我有一个NSLog(@"other");
inBSotherViewController
没有-viewDidLoad
在控制台中显示。控制台中显示的类似NSLog(@"other");
in 。我怀疑问题是缺少一个,但我不知道它应该去哪里以及它应该如何在情节提要中链接。BSViewController
-viewDidLoad
IBAction
BSViewController.h
#import <UIKit/UIKit.h>
@interface BSViewController : UIViewController
@property (nonatomic) NSInteger number;
@end
BSViewController.m
#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.h
#import <UIKit/UIKit.h>
@interface BSotherViewController : UIViewController
@property (nonatomic) NSInteger anumber;
@end
BSotherViewController.m
#import "BSotherViewController.h"
#include "BSViewController.h"
@interface BSotherViewController ()
@end
@implementation BSotherViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
NSLog(@"other number:");
[super viewDidLoad];
// Do any additional setup after loading the view.
BSViewController *view = [[BSViewController alloc] init];
self.anumber = view.number;
NSLog(@"other number: %d", self.anumber);
}