我有一个简单的问题:我的用户可以在UIView
. 我会NSUserDefault
用来保存各种按钮,然后UIView
在应用程序启动时(不是后台)重新加载它们。我该怎么办?
-(void)AddButton:(UIButton*)sender {
CountButton++;
if (CountButton< 11) {
button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button2.frame = CGRectMake(20, 80, 120, 80);
UIImage *buttonImage = [UIImage imageNamed:@"image"];
[button2 setBackgroundImage:buttonImage forState:UIControlStateNormal];
NSString* buttonTitle = [NSString stringWithFormat:@"Button%d", CountButton];
[button2 setTitle:buttonTitle forState:UIControlStateNormal];
NSString *selectorName = [NSString stringWithFormat:@"ButtonAdd%d:", CountButton];
[button2 addTarget:self action:NSSelectorFromString(selectorName)forControlEvents:UIControlEventTouchUpInside];
}}