I'm a bit stumped how to resize custom UIBarButtonItem buttons on device rotation. I'm using the builtin toolbar of navigationitem and I roll out my own buttons like this:
Code:
UIImage *btn0Image = [UIImage imageNamed:@"deleteButtonNormal.png"];
UIImage *btn0ImageOver = [UIImage imageNamed:@"deleteButtonOver.png"];
UIButton *b0 = [UIButton buttonWithType:UIButtonTypeCustom];
b0.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
b0.frame = CGRectMake(0, 0, 71, 44);
[b0 setTag:kDeleteButton];
[b0 setImage:btn0Image forState:UIControlStateNormal];
[b0 setImage:btn0ImageOver forState:UIControlStateHighlighted];
[b0 addTarget:self action:@selector(barButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btn0 = [[UIBarButtonItem alloc] initWithCustomView:b0];
... (several more of the same..)
NSArray *toolbarItems;
toolbarItems = [[NSArray alloc] initWithObjects:btn0, flexSpace, btn1, fixedSpace, btn2, flexSpace, btn3, nil];
[self setToolbarItems:toolbarItems];
When I rotate the device the buttons stay their original size. I have tried to play with the autoresizemask property of the UIbutton I create.
setting flexible height works and squashes the button a small bit, I need the width corrected too though. setting flexible width widens the buttons to take up the entire toolbar rather than scale proportionally.
Any suggestions what to do here??