在我的应用程序中,我有四个按钮和一些文本标签。标签中的文本是通过界面生成器定义的。我不善言辞,所以我希望下面的代码足够清楚,可以指出我正在尝试做的事情。
- (void)viewDidLoad
{
[super viewDidLoad];
//Default view loaded as defined in Interface Builder
}
- (IBAction)button_1_Pressedid)sender {
// Programmatically Change text in Labels
}
- (IBAction)button_2_pressedid)sender {
// Programmatically Change text in labels
}
- (IBAction)button_3_pressedid)sender {
// Programmatically Change text in labels
}
- (IBAction)button_4_pressedid)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.
}
或者也许有办法在按下按钮 4 时重置/“重新启动” View ?
Best Answer-推荐答案 strong>
存储它,使用它。
-(void)viewDidLoad {
self.originalText = self.textField.text;
}
-(void)restore {
self.textField.text = self.originalText;
}
关于iOS - 是否可以将标签/ TextView 重置为在 Interface Builder 中定义的初始状态?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18780928/
|