Can UIView be copied?

后端 未结 6 1613
广开言路
广开言路 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:49

    UIView doesn't implement the NSCoping protocol, see the declaration in UIView.h:

    @interface UIView : UIResponder

    So, if we want to have a copy like method, we need to implement the NSCoping protocol in a category or so.

提交回复
热议问题