Search code examples
iphoneios4multitaskinguitoolbar

UIToolBar creating problem while application returns from background


I am using a uitoolbar in a view that is initialized using initWithFrame: method in sdk. I mean I am adding tool bar porgrammatically. While multitasking, this toolbar is creating problem. Can anyone give me some solution or a ray of light to proceed. I cant add it in xib since I am using a custom uitablecontroller class. My code is as follows:

-(void)viewDidLoad
{

[super viewDidLoad];    
actionToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 373, 320, 44)];  
[actionToolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top-bar.png"]] autorelease] atIndex:0];

actionButton = [NotesList createSquareBarButtonItemWithTitle:@"Delete" target:self action:@selector(noAction:)];
flexibleSpace1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
flexibleSpace2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];    

composeButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(addNewGroup:)]autorelease];
composeButton.style = UIBarButtonItemStylePlain;    
[actionToolbar setItems:[NSArray arrayWithObjects:flexibleSpace1, flexibleSpace2, composeButton, nil]]; 
[self.view.superview addSubview:actionToolbar];

self.tableView.frame = CGRectMake(0, 0, 320, 400);  
[self.tableView setAllowsSelectionDuringEditing:YES];   
[flexibleSpace1 retain];
[flexibleSpace2 retain];
[actionButton retain];
[composeButton retain]; 
[self parseDataForThisFile];
}

Solution

  • I had resolved the code by setting frames of tab bar controller when the app returns from background