我使用以下代码将我的“自定义按钮”存储在 NSUserdefaults 中。但是在将对象转换为 NSdata 时出现错误“[UIImage encodeWithCoder:]: unrecognized selector sent to instance”。这里的“自定义按钮”是 UIButton 类. 有谁知道为什么...?请帮我。
Custom_button *lock11 = (Custom_button*)[menu1 viewWithTag:100];
NSLog(@"opened lock1 ========= %@",lock11);
lock11.is_menu_lock_opened = YES;
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:lock11]; //[NSKeyedArchiver archivedDataWithRootObject:lock11];
[prefs setObject:myEncodedObject forKey:@"set1lock"];