Property type 'id' is incompatible with type 'id _Nullable' inherited from 'UITabBar'

iOS 声明自定义delegate是报警告,类似:
Property type 'id' is incompatible with type 'id _Nullable' inherited from 'UIScrollView'

Property type 'id<XXXXDelegate>' is incompatible with type 'id<UITabBarDelegate> _Nullable' inherited from 'UITabBar'_第1张图片
image.png

通常原因是:由于自定义tabBar,没有继承系统UITabBarDelegate造成的

解决办法
修改点1
将自定义delegate自称自系统的代理


Property type 'id<XXXXDelegate>' is incompatible with type 'id<UITabBarDelegate> _Nullable' inherited from 'UITabBar'_第2张图片
image.png

修改点2

image.png

Xcode会认为自定义的delegate与父类中的delegate重名,所以在.m文件中加上 @dynamic即可
image.png

你可能感兴趣的:(Property type 'id' is incompatible with type 'id _Nullable' inherited from 'UITabBar')