我知道有很多关于这个问题的问题,但是我已经阅读了每个人,但我仍然遇到问题,在所有其他问题中,解决方案是添加一个属性,或者如果询问的人只是忘记将其链接到 ViewController。我已经完成了所有这些,它仍然不会更新!
我的.h:
@property(strong,nonatomic) IBOutlet UITextField *textField;
-(void)setCoords:(NSString *)coordinates tag:(int)tag;
.m
@synthesize textField;
设置从另一个视图切换时调用的文本的函数:
-(void)setCoords:(NSString *)coordinates tag:(int)tag {
NSLog(@"1 %@", textField);
textField = [[UITextField alloc] initWithFrame:CGRectMake(0,0,206,30)];
NSLog(@"2 %@", textField);
if (tag == 0) {
[textField setText:coordinates];
[self.view addSubview:textField];
NSLog(@"3 %@", textField);
}
NSLog(@"%@", textField.text);
}
output
from the总是NSLog
,NULL
但如果我只有NSLog
字符串coordinates
,我会得到字符串。
有什么我错过/不知道/或做错了吗?
更新更新了功能
NSLog 1 loggs NULL
NSLog 2 loggs <UITextField> 0x855b300; frame: = (0 0; 206 30) and some more stuff.
NSLog 3 loggs same as log 2