I have a UIViewController subclass called TripViewController. This class has the following method:
- (void)lockScreen {
LockOverlay *lockOverlay = [[LockOverlay alloc] init];
[self presentModalViewController: lockOverlay animated:YES];
}
LockOverlay is also a UIViewController subclass, defined as follows (the rest of the code is just auto-generated stubs):
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
CGRect frame = CGRectMake(0, 0, 225, 37);
UIImageView *sliderBackground = [[UIImageView alloc] initWithFrame:frame];
sliderBackground.image = [UIImage imageNamed:@"slider-bar.png"];
UIImageView *unlock = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"unlock.png"]];
[sliderBackground addSubview:unlock];
frame = CGRectMake(10, 360, 225, 37);
Slider *slider = [[Slider alloc] initWithFrame:frame];
[slider addSubview:sliderBackground];
slider.unlock = unlock;
[self.view addSubview:slider];
}
When lockScreen gets called, the program goes into an infinite loop, and loadView gets called over and over.
So, what am I doing wrong here? I've had a bug like this before... In the App Delegate, I create a TabBarController, and one of the views has a NavigationController. I got the same sort of bug when I tried to add the View instead of the NavigationViewController to the tabBar array. I assume this problem is similar and I'm not pushing the new ViewController to the right place, but that's just a guess.