I'm working on an app that is setup as follows:
- Tab Bar Controller with four tabs
- All four tabs are setup as navigation controllers
- The tab bar and navigation controller are programatically setup in the app delegate.
- Three of the four tabs utilize table views (hence the navigation)
- The fourth tab is setup just as a view with a picker with labels (also is a navigation controller) and an 'info' button in the top right of the navigation pane.
The 'info' button is setup as follows:
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Create an info page button
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(modalViewAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[self.navigationItem setRightBarButtonItem:modalButton animated:YES];
[modalButton release];
[infoButton release];
[self updateLabels];
}
// Here is the selector action
Code:
- (IBAction)modalViewAction:(id)sender
{
if (self.myInfoViewController == nil)
self.myInfoViewController = [[[MyInfoViewController alloc] initWithNibName:@"MyInfoView" bundle:nil] autorelease];
[self.navigationController presentModalViewController:self.myMotorStartersInfoViewController animated:YES];
}
In the viewDidLoad I setup the arrays.
In the 'second view' that the info button navigates to I using the following with the 'done' button.
Code:
- (IBAction)dismissAction:(id)sender
{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
The issue I am having is the following:
Scenario 1
I run the app, go to the tab with the picker and change the picker values to update the labels on the view. This works ok. If I select the info button, the app crashes.
The error I am getting is:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (13897984) beyond bounds (2)'
Scenario 2
I select the 'info' button in this tab, it opens to another view and I select the 'okay' button to go back to the picker view. Once I go back to the picker view the app crashes after moving the picker wheels. I have the picker setup to update on view did appear like this.
Code:
- (void)viewDidAppear:(BOOL)animated
{
// These are the default values for the picker when the app starts
[myPicker selectRow:0 inComponent:0 animated:YES];
[myPicker selectRow:0 inComponent:0 animated:YES];
}
Do you think this is an issue with releasing objects, etc?