When I try to use an accelerometer program from the Big Nerd Ranch, iPhone book, on my iPhone device, I get the following error...
program received signal: "SIGABRT"
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x118fe0'
The code is from Chapter 8 in the iPhone Big Nerd Ranch book. I have an old iPhone. My OS is 3.1.3 (bought phone in 2007). This program works fine on the simulator, but the accelerometer has no function on the simulator.
Below is the additional code added from a project that was essentially 2 views with a tab bar.
Any help is appreciated. Thanks.
Adam
program received signal: "SIGABRT"
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x118fe0'
The code is from Chapter 8 in the iPhone Big Nerd Ranch book. I have an old iPhone. My OS is 3.1.3 (bought phone in 2007). This program works fine on the simulator, but the accelerometer has no function on the simulator.
Below is the additional code added from a project that was essentially 2 views with a tab bar.
Code:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"Monitoring accelerometer");
UIAccelerometer*a=[UIAccelerometer sharedAccelerometer];
[a setUpdateInterval:0.1];
[a setDelegate:self];
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIAccelerometer sharedAccelerometer]setDelegate:nil];
}
-(void)accelerometer:(UIAccelerometer*)meter
didAccelerate:(UIAcceleration*)accel
{
HypnosisView*hv=(HypnosisView*)[self view];
[hv setXShift:10.0*[accel x]];
[hv setYShift:10.0*[accel y]];
[hv setNeedsDisplay];
}
Any help is appreciated. Thanks.
Adam