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
{
}
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]
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:
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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.