Search code examples
iosobjective-cuiviewuicontrol

Changing UIView To be instance from UIControl Programmatically


I have a button that will change the view's class to UIControl

i have typed this line of code but Xcode say it is a error

-(IBAction)button:(id)sender
{

    self.view.class = [UIControl class];
}

So guys my question is how to change my view's class to UIControl class programmatically


Solution

  • You cant change the class type at runtime. Alternatively you can set your control to stop handling user interactions:

    self.userInteractionEnabled = NO;