0
私はstoryboardを使ったXcodeプログラミングで初心者です。 "SecondViewController"から "View Controller"に値(ラベルのテキスト)を渡そうとしています。ここで が私のコードです:2つのビュー間で値を渡す - Xcode 4.2 with storyboard
ViewController.m
- (IBAction)showSecondView:(id)sender {
NSLog(@"Trying..");
// The identifier used here is set on the second view controller in the UIStoryboard.
SecondViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondIdentifier"];
NSLog(@"Test: %@",svc.labelTest.text); //this print NIL!!
svc.labelTest.text = @"GOOFY!!";
[self.navigationController pushViewController:svc animated:YES];
}
SecondViewController.h
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
- (IBAction)returnToFirstView:(id)sender;
- (IBAction)toTabBar:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *labelTest;
@end
SecondViewController.m
#import "SecondViewController.h"
@implementation SecondViewController
@synthesize labelTest;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
誰かが私を助けてくださいだろうか? ありがとうございます!
ステファノ
をあなたにSchnarchiiをありがとう!私は私の問題を解決しました! –
問題はありません:)それは私のためではなく、他の答えを受け入れるよりも助けている場合。だから、もし彼らが似たような問題を抱えていれば、彼らは最良の解決策を選ぶことができますそれはあなたとstackoverflowを助けた.. – Quirin