Problem in Shake Event when using Flip View (IPhone)
I have a problem in reacting to a shake event. First problem is that if I place the shake view on root then it works fine, but when i flip to other views and come back it doesn't work at all. Second problem is that if I use shake and then flip to a view which has a UITextField in it then UITextField does not respond and no keyboard appears. I can provide my code if any body wants. Needing to resolve this issue badly.
Regards.
Edit:
Following is the code of root view (where i am using shake event):
enter -(BOOL) canBecomeFirstResponder{
return YES;}
-(void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self becomeFirstResponder];}
-(void) viewDidDisappear:(BOOL)animated{
[self resignFirstResponder];
[super viewDidDisappear:ani开发者_如何学Gomated];}
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if(event.subtype == UIEventSubtypeMotionShake)
{
iv.transform = CGAffineTransformMakeScale(1.0, 1.0);
txtviewFortune.text = nil;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
iv.transform = CGAffineTransformMakeScale(2.0, 2.0);
[UIView commitAnimations];
}
}
Just use viewWillDissappear method not viewDidDissappear.
精彩评论