Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 向UITextField添加文本字符串_Objective C_Ios - Fatal编程技术网

Objective c 向UITextField添加文本字符串

Objective c 向UITextField添加文本字符串,objective-c,ios,Objective C,Ios,我无法将数据从ivar传递到以编程方式创建UITextField。以下是我目前拥有的: 你会注意到我正在使用通知中心 同一文件中的不同方法 self.button.text = self.ivar; 上面的代码没有显示self.ivar的内容。然而,如果我写: self.button.text = @"some text"; 这是正常的,一些文本显示在文本字段中。 我在这里做错了什么?您可以在通知方法中这样做,以便将按钮文本设置在那里吗 self.ivar = [NSString strin

我无法将数据从ivar传递到以编程方式创建UITextField。以下是我目前拥有的:

你会注意到我正在使用通知中心

同一文件中的不同方法

self.button.text = self.ivar;
上面的代码没有显示self.ivar的内容。然而,如果我写:

self.button.text = @"some text";
这是正常的,一些文本显示在文本字段中。
我在这里做错了什么?

您可以在通知方法中这样做,以便将按钮文本设置在那里吗

self.ivar = [NSString stringWithFormat:@"%@", [[notification userInfo] objectForKey:@"DO"]];
NSlog(@"%@", self.ivar); // It is OK Correctly display the string from self.ivar
self.button.text = self.ivar;

您能否验证self.button.text=self.ivar在分配后是否被调用?在运行
self.button.text=self.ivar之前是否收到通知代码???实际上我在self.button.text=self.ivar之后收到通知。该按钮是在loadview方法中创建的。如何修复?使用上面的代码,没有人可以修复任何东西。。。
self.ivar = [NSString stringWithFormat:@"%@", [[notification userInfo] objectForKey:@"DO"]];
NSlog(@"%@", self.ivar); // It is OK Correctly display the string from self.ivar
self.button.text = self.ivar;