简体   繁体   中英

How can I decide if switch view value was changed by user interaction or by code in IOS?

I have a switch view on my UI and I'd like to handle the event when its value is changed. To perform this I've made an IBAction method to handle value changed event. So far so good.

My problem is I can't decide if change was performed by - code (it may happen in my app) - user interaction

How can I decide if it was changed by a user interaction or by code?

Is there a specific method that changes the switch value when it's done by code only? If so, maybe you could use that method to set a boolean/flag to check against when you need to decide/handle the event.

In Apple ScrollView / ScrollPages Example they have a simmilar situation:
They have to decide whether an event was self(=code) triggered, or by the user.
They simply set a variable (before programatically calling) to distinguish between this two situations.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM