Basically I have an IOS app that uses a Picker. When the Picker is used to select that item of interest I use an API to communicate remotely to a db. I would like to disable the Picker while waiting on the response. I need to disable further Picker movement until a response or time out has occurred.
Is there a way to set Picker.Enabled = False and then when either response received or comm timeout occurs then set Picker.Enabled = True?
I could not find a way to do this for IOS Picker in a similar manner as I would for Desktop or Web PopUpMenu so I created another View that is populated after the PickerSelection has been made.
@Jason King Very Cool and Thank you. At first this errored then I used āselectorā as keyword to search and found examples in the UIKit. Then I made slight syntax update and all is good .
Declare sub setUserInteraction lib "UIKit.framework" selector "setUserInteractionEnabled:" (obj_id as ptr, en as Boolean)
setUserInteraction(myPicker.Handle, false)
If I missed documentation on this my bad but if not this is hugely valuable.
This is extending the ask. I looked through the UIKit on how to lock rotation to Portrait or Landscape then enable rotation. My thoughts are if I could find the correct selector I may have a solution. How close am I?
Unfortunately locking rotation for a specific view isnāt as easy as writing a declare.
You actually need to override a property/method at system level.
This would be the Swift code:
[code]override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.all //return the value as per the required orientation
}
I canāt seem to find it and fear it was on my old laptop that died a few years back. I know that it can be done using method swizzling like I did for the ImprovediOSApplication class since getters in objective-c are still just functions that can be overridden. If that project doesnāt provide enough info to get to the bottom of this please let me know and I can try to help but Iām not going to have the time to test this for a couple months.
To get the values of constants you can use a Swift playground. Make a new playground and type:
[code]import UIKit
var test = UIInterfaceOrientationMask.All.rawValue[/code]
And you will see that the value of that constant is 30. You can do the same with all the others and find they are:
āa few years backā those functions where āfunctionsā today they are ācomputed propertiesā as denoted by the āvarā
I donāt recall which iOS version changed that ā¦ but they went from āfuncā to āvarā ā¦ so what you had working in the past probably wouldnāt work today.
Alsoā¦ as a side noteā¦ not all those orientations work on the āXā models of iPhones
It changed for just this property? in Objective C too? Or just swift? Because all properties that my declares access are using functions so IĀm pretty sure it will still work. I definitely believe that the way swift does it could have changed, but since Objective C is still supported and now declares need to work I think we should be ok.
Noā¦ there were a few that changedā¦ and I wouldnāt think Apple would change it for just Swift or just ObjC since both are tied to the same framework
and based on what I see in Apples docsā¦ both ObjC and Swift use āsimilarā syntax for these
I know for sure that
prefersStatusBarHidden
preferredStatusBarStyle
supportedInterfaceOrientations
shouldAutorotate
all changedā¦ probably in iOS9 (but Iām guessing)
[quote=432557:@Jason King]To get the values of constants you can use a Swift playground. Make a new playground and type:
[code]import UIKit
var test = UIInterfaceOrientationMask.All.rawValue[/code]
And you will see that the value of that constant is 30. You can do the same with all the others and find they are: