Custom UIView issue

I have a custom UIView class and I have linked my view in IB to this class. in my own class, I have a function

 -(void)replaceSubview:(UIView*)view1 withSubView:(UIView*)view2;

      

so in my view controller, I was calling this function like this:

   [self.view replaceSubview:view1 withSubview:view2];

      

however the function is working correctly, but give me a warning how UIView might not respond to this function and it is supposed to return an id, I don’t know how this happens as I have my custom class reference to the view in IB alr, help using pls

+1


a source to share


1 answer


The property is view

defined in UIViewController and is typed as UIView *

. If you want to get rid of the warning, you need to throw it first:



MyView *myView = (MyView *)self.view;
[myView replaceSubview:view1 withSubview:view2];

      

+2


a source







All Articles