I am having an intermittent problem with a TableView. When testing the app on my iPad it can work fine for days. But every now and then when I return to my root viewController the entire table view is gone. Not just the text from the array but the whole tableView it's self is missing. It happens so intermittently and it isn't crashing the app so there is no crash report that can give me clues.
I am using ARC so I don't need to release the objects myself.
My header file
In my implementation I instantiate the the object within an if statement that checks to see if it already exists in the first place.
I can't think of any other place in the code that it would be causing. There is no other method in this Class that references this tableView, it is all within the viewDidLoad. Can anyone see anything wrong with this code?
Thanks!
I am using ARC so I don't need to release the objects myself.
My header file
Code:
#import <UIKit/UIKit.h>
#import "BoilerPlateCode.h"
#import "MainVC.h"
#import <AVFoundation/AVFoundation.h>
@interface WelcomeVC : UIViewController <UIAlertViewDelegate, UITableViewDataSource, UITableViewDelegate>{
int pickerSelected;
NSMutableArray *characterArray;
IBOutlet UIButton *muteMusic;
IBOutlet UIImageView *tableViewWhiteWash;
AVAudioPlayer *audioPlayer;
UITextField *nameField;
NSMutableDictionary *mainCharacterDict;
[COLOR="Red"]UITableView *characterListTableView;[/COLOR]
UIAlertView* dialog;
UIAlertView *alertDelete;
}
- (IBAction)continueButton:(id)sender;
- (IBAction)deleteButton:(id)sender;
- (IBAction)muteMusicButton:(id)sender;
@end
In my implementation I instantiate the the object within an if statement that checks to see if it already exists in the first place.
Code:
#import "WelcomeVC.h"
@implementation WelcomeVC
-(void)viewWillAppear:(BOOL)animated{
self.navigationController.navigationBar.hidden = YES;
pickerSelected = -1;
if (!characterListTableView) {
characterListTableView = [[UITableView alloc] initWithFrame:CGRectMake(625, 171, 272, 388) style:UITableViewStylePlain];
characterListTableView.dataSource = self;
characterListTableView.delegate = self;
characterListTableView.backgroundColor = [UIColor clearColor];
characterListTableView.separatorColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.7];
characterListTableView.opaque = NO;
characterListTableView.backgroundView = nil;
[characterListTableView.layer setBorderColor: [[UIColor blackColor] CGColor]];//set black boarder around notefield
[characterListTableView.layer setBorderWidth: 2.0];//set black boarder thikness
CALayer * btv = [characterListTableView layer]; // rounds the edges of the noteField
[btv setMasksToBounds:YES];
[btv setCornerRadius:10.0];
[self.view addSubview:characterListTableView];
}
[tableViewWhiteWash setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.3]];
CALayer * bvbg = [tableViewWhiteWash layer]; // rounds the edges of the noteField
[bvbg setMasksToBounds:YES];
[bvbg setCornerRadius:10.0];
[self loadCharecters]; // sets up the tableView array
[characterListTableView reloadData];
[audioPlayer play];
}
I can't think of any other place in the code that it would be causing. There is no other method in this Class that references this tableView, it is all within the viewDidLoad. Can anyone see anything wrong with this code?
Thanks!