I'm trying to make some updates to an app of mine written in ObjectiveC to adopt new iOS 13 features. I'm looking at the interactive dismissal handling of the new way of modally presenting View controllers and after detecting changes in my controller i wish to stop interactive dismissals and present a dialogue to the user as recommended by Apple. Attempting to do so with the following code
self.isModalInPresentation = YES;
doesn't compile with the following error
No setter method 'setIsModalInPresentation:' for assignment to property
Going to the implementation of this property from my ObjectiveC project goes to the ObjectiveC header with the property defined as follows
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation API_AVAILABLE(ios(13.0));
Looking at the same property within a swift project reveals the following swift definition for it
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@available(iOS 13.0, *)
open var isModalInPresentation: Bool
Is this just an oversight on Apple's part with the ObjectiveC source? I can't find any setIsModalInPresentation function or access it directly via _isModalInPresentation. It's been a while since I did any significant work in ObjectiveC so my language knowledge is rusty, am I expected to synthesize the property in my subclass? As there's already a getter implemented I'm not even sure how that would work.
I'm on Xcode 11.0, I guess I could look to see if this is fixed in later versions of Xcode/iOS?
Any help as ever is appreciated, cheers
Try this:
self.modalInPresentation = YES;
As mentioned in question, it is defined as follows,
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation;
That means you need to set it as self.modalInPresentation = YES;
. isModalInPresentation
is a getter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With