美文网首页iOS归纳
iOS 关于View的复制问题

iOS 关于View的复制问题

作者: Sh1mmer | 来源:发表于2019-03-22 13:33 被阅读0次

在今天碰到了一个问题就是复制控件

self.view = other.view
//我们这样写会发现当other.view销毁时self.view也会变为空白.
//或许可以理解为浅拷贝
//我们可以通过下面的方法来实现控件复制
NSData *tempArchive = [NSKeyedArchiver archivedDataWithRootObject:other.view]; 
self.view = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchive];

相关文章

网友评论

    本文标题:iOS 关于View的复制问题

    本文链接:https://www.haomeiwen.com/subject/psydeqtx.html