UII需要copy,self controller或者self.view,我试过了:
UIView* viewOfSelf =[self.view copy];
UIViewController* controller = [self copy];
UIView* viewOfSelf =[self.view mutableCopy];
UIViewController* controller = [self mutableCopy];
错误是:
-[UIViewController mutableCopyWithZone:]: unrecognized selector sent to instance 0xb803490
-[UIView copyWithZone:]: unrecognized selector sent to instance 0x6e0acb0
最佳答案
使用 -
NSData *tempArchiveView = [NSKeyedArchiver archivedDataWithRootObject:self.view];
UIView *viewOfSelf = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchiveView];
同样-
NSData *tempArchiveViewController = [NSKeyedArchiver archivedDataWithRootObject:self];
UIViewController *controller = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchiveViewController];
关于objective-c - 克隆或复制 UIViewController 或 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10614276/