iOS - 是否可以将标签/ TextView 重置为在 Interface Builder 中定义的初始状态?
<p><p>在我的应用程序中,我有四个按钮和一些文本标签。标签中的文本是通过界面生成器定义的。我不善言辞,所以我希望下面的代码足够清楚,可以指出我正在尝试做的事情。</p>
<pre><code>- (void)viewDidLoad
{
;
//Default view loaded as defined in Interface Builder
}
- (IBAction)button_1_Pressed:(id)sender {
// Programmatically Change text in Labels
}
- (IBAction)button_2_pressed:(id)sender {
// Programmatically Change text in labels
}
- (IBAction)button_3_pressed:(id)sender {
// Programmatically Change text in labels
}
- (IBAction)button_4_pressed:(id)sender {
// Change text in labels back to the values when the view first loaded.
// That is, to the text defined in Interface builder instead of changing
// it back programmatically.
}
</code></pre>
<p>或者也许有办法在按下按钮 4 时重置/“重新启动” View ?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>存储它,使用它。</p>
<pre><code>-(void)viewDidLoad {
self.originalText = self.textField.text;
}
-(void)restore {
self.textField.text = self.originalText;
}
</code></pre></p>
<p style="font-size: 20px;">关于iOS - 是否可以将标签/ TextView 重置为在 Interface Builder 中定义的初始状态?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18780928/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18780928/
</a>
</p>
页:
[1]