Clone or Copy UIViewController or UIView

前端 未结 3 1068
野的像风
野的像风 2020-12-17 14:43

UII need copy, self controller or self.view, i have tried:

UIView* viewOfSelf =[self.view copy];
UIViewController* controller = [self copy];

UIView* viewOfS         


        
3条回答
  •  时光说笑
    2020-12-17 15:26

    Use -

    NSData *tempArchiveView = [NSKeyedArchiver archivedDataWithRootObject:self.view];
    UIView *viewOfSelf = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchiveView];
    

    Similarly -

    NSData *tempArchiveViewController = [NSKeyedArchiver archivedDataWithRootObject:self];
    UIViewController *controller = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchiveViewController];
    

提交回复
热议问题