[英]Modal View Shake Gesture
I am having an issue with using a shake gesture with modal view switching. 我在使用模态视图切换的摇动手势时遇到问题。 The shake gesture works when I move into the specified view controller the first time.
第一次进入指定的视图控制器时,摇动手势有效。 When I exit and return however, it does not.
但是,当我退出并返回时,它不会。 I have implemented the can become first responder and viewdidAppear techniques, and the console detects a shake using an NSLog entry, but nothing happens.
我已经实现了可以成为第一响应者和viewdidAppear技术的方法,并且控制台使用NSLog条目检测到抖动,但是没有任何反应。 Everything else seems to work but it won't initiate the actions of a shake on second viewing.
其他所有内容似乎都可以使用,但不会引起第二次观看时的震动。
Any help or insight would be greatly appreciated 任何帮助或见识将不胜感激
please let me know what other pieces of code would be helpful - 请让我知道其他代码段会有所帮助-
-(BOOL)canBecomeFirstResponder {
return YES;}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
// Put in code here to handle shake
NSLog(@"Shaken");
time = 9.0;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countdown) userInfo:nil repeats:NO];
myAnimatedView.hidden = NO;
myAnimatedView2.hidden = NO;
myAnimatedView3.hidden = NO;
webViewRandomizer.hidden = YES;
backToRandomizer.hidden = YES;
backToRandomizerBG.hidden = YES;
backRandomizer.hidden = YES;
forwardRandomizer.hidden = YES;
backToRandomizerMenu.hidden = YES;
tweetView.image = [UIImage imageNamed:@"3988567990_60d8da5cdf_o.jpg"];
[webViewRandomizer resignFirstResponder];
[self becomeFirstResponder];
[myAnimatedView setAnimationRepeatCount:6];
[myAnimatedView2 setAnimationRepeatCount:2];
[myAnimatedView3 setAnimationRepeatCount:1];
myAnimatedView.animationDuration = 0.5;
myAnimatedView2.animationDuration = 3.0;
myAnimatedView3.animationDuration = 9.0;
[myAnimatedView startAnimating];
[myAnimatedView2 startAnimating];
[myAnimatedView3 startAnimating];
NSURL *url = [NSURL URLWithString:@"http://historicaltweets.com/"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webViewRandomizer loadRequest:requestObj];
[self performSelector:@selector(aShowRandomizer) withObject:nil afterDelay:10.0f];}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] ){
[super motionEnded:motion withEvent:event]; }}
#define kUpdateInterval (1.0f/60.0f)
- (void)viewDidAppear:(BOOL)animated{
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = kUpdateInterval;
[super viewDidAppear:animated];
[self becomeFirstResponder];}
- (void)viewDidDisappear:(BOOL)animated{
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = nil;}
-(IBAction)backToRandomizerMenuGo{
[self dismissModalViewControllerAnimated:YES];}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.