Open Rigter opened 11 years ago
Finally!
I've solved my problem adding removedOnCompletion into JLBPartialModal.m
- (CAKeyframeAnimation *)pullBackAnimation
- (CAKeyframeAnimation *)pushForwardAnimation
Like this:
- (CAKeyframeAnimation *)pullBackAnimation
{
CATransform3D startTransform = [self perspectiveTransform];
CATransform3D endTransform = CATransform3DConcat([self windowScaledTransform], startTransform);
CATransform3D middleTransform = CATransform3DConcat([self windowRotationTransform], startTransform);
CAKeyframeAnimation *anim = [self windowAnimation];
anim.values = @[[NSValue valueWithCATransform3D:startTransform], [NSValue valueWithCATransform3D:middleTransform], [NSValue valueWithCATransform3D:endTransform]];
anim.removedOnCompletion = YES; // Line added
return anim;
}
- (CAKeyframeAnimation *)pushForwardAnimation
{
CATransform3D endTransform = [self perspectiveTransform];
CATransform3D startTransform = CATransform3DConcat([self windowScaledTransform], endTransform);
CATransform3D middleTransform = CATransform3DConcat([self windowRotationTransform], startTransform);
CAKeyframeAnimation *anim = [self windowAnimation];
anim.values = @[[NSValue valueWithCATransform3D:startTransform], [NSValue valueWithCATransform3D:middleTransform], [NSValue valueWithCATransform3D:endTransform]];
anim.removedOnCompletion = YES; // Line added
return anim;
}
With this I make sure that the animations are removed :D
hm this doesn't working for me. With this fix the back-view will be shown with his original full size frame on the end of the animation.
Could you put the code here?
I'm having no special code. Just take the demo project and put an UISearchBar on top of the PartialModalView. First time UISearchBar becomes first responder everything works well. From the second time on the keyboard will shown with the wrong size. The problem is, that I'm presenting a half screen size view. So the MainView is still visible in the back. In the moment the animation is removed the back view get his original (full) size.
I'm using this for my app, hope this helps:
In the secondView:
Tip: self.texto is a UITextView
- (void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillHide:) name:UIKeyboardDidHideNotification object:nil];
}
-(void)KeyboardWillHide:(NSNotification *) notification {
[[JLBPartialModal sharedInstance] dismissViewController];
}
#pragma mark - Partial modal delegate
- (void)didPresentPartialModalView:(JLBPartialModal *)partialModal
{
self.texto.editable = YES;
[self.texto becomeFirstResponder];
}
- (BOOL)shouldDismissPartialModalView:(JLBPartialModal *)partialModal
{
return YES;
}
- (void)didDismissPartialModalView:(JLBPartialModal *)partialModal
{
}
I have a close button in my view, when is touched the action is:
- (IBAction)close:(id)sender
{
self.texto.editable = NO;
[self.texto resignFirstResponder];
}
In first place this action only hides the keyboard but fires a NSNotification with the name UIKeyboardDidHideNotification, this notification is executed when the keyboard hiding animation is ending, then, this notification calls a custom method called KeyboardWillHide where I dismiss de view.
Try this, maybe you find a solution.
Dont forget to add the little fix that I found
thank you for your advice. But with your code "anim.removedOnCompletion = YES;" the view in the back will shown with his normal size. (see picture 2)
first time:
with your fix:
second time and ongoing:
Hi.
My problem is this, when I try to show the keyboard at the second view, the first time this happens everything looks fine, the problem comes the second time, the keyboard is smaller but still works in its original size.
First Time
Second Time
I do not know if there is any way to force the second view has the becomeFirstResponder.
Hopefully have any suggestions to solve my problem.
First View
View is called using a IBAction
Second view
The class have 3 delegates, one of them didPresentPartialModalView, I'm using this delegate for show the keyboard after the view and animation ends:
Then, when the user touch Close button the UITextView have resignFirstResponder and with the NSNotificationCenter I know that the keyboard is hidden:
Thanks!