0
我在使用模態視圖切換的搖擺手勢時遇到問題。當我第一次進入指定的視圖控制器時,搖動手勢起作用。但是,當我退出並返回時,它不會。我已經實現了可以成爲第一響應者和viewdidAppear技術,並且控制檯使用NSLog條目檢測到震動,但沒有任何反應。其他一切似乎都有效,但它不會在第二次觀看時發起動作。Modal View Shake手勢
任何幫助或洞察力將不勝感激
我在使用模態視圖切換的搖擺手勢時遇到問題。當我第一次進入指定的視圖控制器時,搖動手勢起作用。但是,當我退出並返回時,它不會。我已經實現了可以成爲第一響應者和viewdidAppear技術,並且控制檯使用NSLog條目檢測到震動,但沒有任何反應。其他一切似乎都有效,但它不會在第二次觀看時發起動作。Modal View Shake手勢
任何幫助或洞察力將不勝感激
請讓我知道什麼其他代碼段將是有益的 -
-(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];}
發佈您的代碼,請。 – 2009-12-11 19:31:12