I am facing a bit strange problem with implementation of UIAccelerometer. I have a UITableViewController where I don't wanna use UIAccelerometer, but after pressing on of the rows I wanna activated one inside a UIViewController, everything is fine when I use simulator, but when I use device iPhone 3G to test it, I got EXC_BAD_ACCESS by pressing return button.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ShakeControl *percView = [[ShakeControl alloc] init]; // ... // Pass the selected object to the new view controller. [self.navigationController pushViewController:percView animated:YES]; [percView release]; }
It works fine when I disable [percView release];, but it does not sounds like solution for. Any Idea would be appreciated.
Shake control implementation:
- (void)viewDidLoad { [super viewDidLoad]; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:1.0 / kUpdateFrequency]; [[UIAccelerometer sharedAccelerometer] setDelegate:self]; } - (void)viewDidUnload { [super viewDidUnload]; [[UIAccelerometer sharedAccelerometer] setDelegate:nil]; }
Thx