まったく同じコードでこれを何度も実行しましたが、何らかの理由で今日は機能しません。
ExampleViewController1 *exampleView = [[ExampleViewController1 alloc] initWithNibName:@"ExampleViewController1" bundle:nil];
[exampleView setProjectName:[[self.projectListArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
NSLog(@"%@", [[self.projectListArray objectAtIndex:indexPath.row] objectForKey:@"name"]);
XAppDelegate.stackController pushViewController:exampleView fromViewController:nil animated:YES]
私のNSLogプリントアウトは適切です。
My ExampleViewController1.h次のように宣言されたファイル:
@property(nonatomic, strong) NSString *projectName;
次に、このコードを で実行しExampleViewController1.mます
-(void)viewDidLoad {
NSLog(@"%@", self.projectName);
self.projectNameLabel.text = self.projectName;
[super viewDidLoad];
}
私の結果NSLogは興味深いものです。私のNSLogからは、viewDidLoad私の他のものの前に呼び出されているようです:
2012-04-22 10:59:41.462 StackedViewKit[43799:f803] (null)
2012-04-22 10:59:41.463 StackedViewKit[43799:f803] NewTest
(null)からの値があることを確認しましたNSLog(@"%@", self.projectName);が、それは 2 番目に呼び出されたはずNSLogです... なぜ最初に来るのかわかりません。
誰かがこのコードをリクエストしました:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// random color
self.view.backgroundColor = [UIColor colorWithRed:((float)rand())/RAND_MAX green:((float)rand())/RAND_MAX blue:((float)rand())/RAND_MAX alpha:1.0];
}
return self;
}