using knsemimodalviewcontroller with IIViewDeckController?
uzman opened this issue · 17 comments
hi,
im using IIViewDeckController in my project.
presentSemiViewController works great, but when i hit the dismiss button in the modalviewcontroller, it gives error:
Assertion failure in -[IIViewDeckController kn_optionsOrDefaultForKey:]
Defaults must have been set when accessing options.
how can i solve it?
Please update the library, I merged all pending Pull Requests and made some changes.
I don't provide support for implementation issue related to other libraries.
i just wanted to get your opinion.
i think iiviewdeck doesnt have dismissSemiModalView method.
ok, thanks.
I will file this issue. Because i am using IIViewDeck in some of my projects too. Maybe i can reproduce this kind of bug.
it would be great.
could you provide a sample project repo?
I am also having the same problem with KNSemiModalViewController + IIViewDeckController and i am trying to find a solution. When i tap the button to present the modal view controller it takes about 2 seconds to load it. And also when dismissing it you get the error "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Defaults must have been set when accessing options.'" from the NSAssert(defaults, @"Defaults must have been set when accessing options."); at NSObject+YMOptionsAndDefaults.m
Anyone found a solution for this?
Thanks in advance!
This is essentially the same as this issue: #30
I have kind of fixed it but the real issue is that you are using it incorrectly: the presenting controller and the dismissal controller are not the same one.
Thanks for your answer! I can't understand what i am using incorrectly.
At my main view i have a UIMenuController and when pressing a UIMenuItem i present the semi modal VC using:
-
(void)showSemiModal:(id)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil];
MySemiModalVC = (MyModalViewController *) [storyboard instantiateViewControllerWithIdentifier:@"MyModalSB"];[self presentSemiViewController:MySemiModalVC withOptions:@{
KNSemiModalOptionKeys.pushParentBack : @(NO),
KNSemiModalOptionKeys.animationDuration : @(0.3),
KNSemiModalOptionKeys.shadowOpacity : @(0.3)
}];
}
The semi modal controller takes about 2 seconds to start appearing. The dismiss works perfect if i touch the grayed previous view, but if i try to dismiss it with a button with:
UIViewController * parent = self.parentViewController;
if ([parent respondsToSelector:@selector(dismissSemiModalView)]) {
[parent dismissSemiModalView];
}
the semi modal just disappears without the animation.
(All these with your new version you suggested)
Thanks again for your help!
As I said, you got the wrong idea. The "parent" is not the original "self"!
What you need to do is calling dismiss on your child controller, that is the MySemiModalVC controller.
Ok you 're right, if i dismiss it on the child controller it dismisses, but now after the semi modal is dismissed the back-parent view still stays grayed out and if i tap it is enabled again. Is this normal?
Also do you have any idea, why it takes so much time for the semi modal to appear? I 've tested on many devices including iPhone 5 and it still needs about 2 secs, exactly the same time it needs at an iPhone 4. So i don't think its a device performance issue.
It's clearly a hierarchy issue to me. You need to know what's in your hierarchy and perhaps try to call the correct one.
there is another ticket in here about performance and the guy turned out to have tons of UI buttons on screen. You don't happen to have 20+ components in your storyboard view controller do you?
Its just a uitableview and when you tap a cell a UIMenuController pops with 2 options, one of them opens the semi modal VC. and also at my semi modal, again a tableview with 5-10 rows and a toolbar.
Try the demo project. If it takes 2 seconds then something is wrong with your phones.
No the demo works fine. I think the problem occurs when you combine IIViewDeckController and KNSemiModalViewController, and thats why i asked here if anyone have found a solution.
Can you send the entire project?
NOTE TO OTHERS: Do NOT ask for support for IIViewDeckController anymore. There is nothing wrong with it and my library. It is your code!
I have been solved this problem.
please use window.rootViewController, not self to call presentSemiViewController....
this is my code , hope it will hepl you.
[[AppDelegate sharedAppDelegate].window.rootViewController presentSemiViewController:shareViewController withOptions:@{
KNSemiModalOptionKeys.pushParentBack : @(YES),
KNSemiModalOptionKeys.animationDuration : @(0.3),
KNSemiModalOptionKeys.shadowOpacity : @(0.3),
KNSemiModalOptionKeys.parentScale : @(0.95),
}];
this is dismiss:
if ([[AppDelegate sharedAppDelegate].window.rootViewController respondsToSelector:@selector(dismissSemiModalView)]) {
[[AppDelegate sharedAppDelegate].window.rootViewController dismissSemiModalView];
}