我尝试将 NSString 从一个 View 传递到另一个 View ,但不起作用。我在 SecondViewController 中设置了一个 NSString 作为属性
@property (assign) NSString * wert1;
当我通过在 FirstViewController 上按下按钮加载 SecondViewController 时,我尝试传递 NSString:
SecondViewController *Second = [[SpinViewController alloc] initWithNibName:nil bundle:nil];
Second.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"black.png"]];
[Second setWert1:texteingabe1]; //HERE <<<<
Second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:Second animated:YES];
[Second release];
在 SecondViewController 中我做了这个:
NSLog(@"%@",wert1);
但是 NSLog 只是说:(null)。为什么?
感谢您的帮助,并对我的英语不好表示歉意。
最佳答案
你在哪里调用 NSLog
语句?如果它在 loadView
或 viewDidLoad
中,它将不起作用,因为在您的示例中调用 setWert1:
之前调用这些方法。
此外,请确保在调用 NSLog
之前,您没有将其设置为 nil,当然,请确保 texteingabe1
实际上是,传入时不为零。
关于iphone - 无法将 NSString 从一个 View 传递到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2039083/