English 中文(简体)
我如何防止一种具体的观点来应对动摇的姿态?
原标题:How do I prevent a specific view from responding to shake gestures?

我用沙克姿态申请我,但我有问题!

My application is a multiview application and i want use shake gesture on the view 2. If i active shake gesture on view 2, I have to write the code below in the MainViewController.m and MyView2Controller.m to use the shake gesture.

接着,如果我打听电话,就会对这两种观点进行警示,而我则想这样做。 我只想看到第2点。 因此,如果对《第一号主要意见》的守则不采取行动,它就不再发挥作用了。

任何帮助都值得赞赏。

alt text http://www.freezpic.com/pics/98f1465147344642e3870bb599eba689.jpg

我的法典如下:

-(BOOL)canBecomeFirstResponder {
    return YES;
}

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self becomeFirstResponder];
}

-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{
    if (event.subtype == UIEventSubtypeMotionShake)
    {
        UIAlertView *alet =[[UIAlertView alloc]initWithTitle:nil message:@"Shake shake shake" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alet show];
        [alet release];
        self.view.backgroundColor = [UIColor orangeColor];

    }
}
最佳回答

• i 解决了我的问题:

#define kAccelerationThreshold        2.2
#define kUpdateInterval               (1.0f/10.0f)

@interface info : UIViewController  <UIAccelerometerDelegate> {

}
@end

~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

@implementation info


- (void)viewDidLoad {
    UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
    accel.delegate = self;
    accel.updateInterval = kUpdateInterval;


    [super viewDidLoad];
}


#pragma mark -
- (void)accelerometer:(UIAccelerometer *)accelerometer 
        didAccelerate:(UIAcceleration *)acceleration {
   {
        if (acceleration.x > kAccelerationThreshold 
            || acceleration.y > kAccelerationThreshold
            || acceleration.z > kAccelerationThreshold) {


//What do you want to do !

            self.view.backgroundColor = [UIColor orangeColor];



        }
    }
}
问题回答

我认为,你的守则是你们的第二点看法(你想对sha的姿态作出回应)。 在该案中,你完全需要将这种观点控制者的第一反应者身份重新贴在GviewWillDisappear:

- (void)viewWillDisappear:(BOOL)animated 
{
    [super viewWillDisappear:animated];
    [self resignFirstResponder];
}

第二位观点控制器将停止对沙克姿态作出反应。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签