tags:

views:

912

answers:

1

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

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

so in my viewcontroller, i have called this function like this way:

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

however,the function work properly but give me the warning said like UIView may not respond to this function and will be assumed to return id,i dont know how it happen since i have link my custom class to the view in IB alr,pls help

+1  A: 

The property view is defined in UIViewController, and typed as UIView *. If you want to get rid of the warning you need to cast it first:

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