Can UIView be copied?

后端 未结 6 1614
广开言路
广开言路 2020-11-27 15:02

Simply using this way:

UIView* view2 = [view1 copy]; // view1 existed

This will cause simulator can not launch this app.

Try retai

6条回答
  •  天涯浪人
    2020-11-27 15:53

    this might work for you ... archive the view and then unarchive it right after. This should give you a deep copy of a view:

    id copyOfView = 
    [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:originalView]];
    

提交回复
热议问题