iOS - How To Make my view so that it doesn't respond to events

94 views Asked by At

i have asked this question Changing UIView To be instance from UIControl Programmatically 24 minutes ago but i he didn't benefit me , so i typing this question in another form hoping that you can help me

i have a view that its class is from UIControl (so of course it will receive events) and i have a button that i want it to change my view to normal UIView instance (so of course it will receive events)

so how to make that

i want the code if changing the view to UIView here

-(IBAction)pauseButton:(id)sender
{
   //here
}

i want the code of changing the view to UIControl here

-(IBAction)playButton:(id)sender
{

}
2

There are 2 answers

1
Kelly Bennett On

You can not change an object's class in objective-c. If you just want the control to stop receiving touches, you can use:

 [self setUserInteractionEnabled:NO]
0
Tom On

Firstly make sure you have an IBOUTLET for that view or object and make sure it is connected.

For example we will say the view is called the_view

Now you can over uncheck the UserInteractionEnabled checkbox within the interface builders property tab of that object or type a line of code. The second option is better if you want the button to raise the event of stopping touches being allowed.

For the first option I have uploaded a video showing the basic steps:

Click Here For tutorial

For the second on option you can use this code:

the_view.userInteractionEnabled = NO;

Or if you are trying to hide your default view simply use:

self.view.userInteractionEnabled = NO;

or as noted in the answer above:

[self setUserInteractionEnabled:NO]