How to resize a UIButton in a UITableView footer when orientation changes?

It should work with autoresizingmasks, I've done it before but it's important to set the with of your view correctly and add the correct sizingmasks Some sample code to show how it works. This creates two buttons resizing whem you rotate (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = UIView alloc initWithFrame:CGRectMake(0, 0, tableView.frame.size. Width, 50); view.

BackgroundColor = UIColor redColor; UIButton *buttonA = UIButton buttonWithType:UIButtonTypeRoundedRect; buttonA. Frame = CGRectMake(20, 5, 125, 40); buttonA setTitle:@"ButtonA" forState:UIControlStateNormal; buttonA. AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; view addSubview:buttonA; UIButton *buttonB = UIButton buttonWithType:UIButtonTypeRoundedRect; buttonB.

Frame = CGRectMake(175, 5, 125, 40); buttonB setTitle:@"ButtonB" forState:UIControlStateNormal; buttonB. AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; view addSubview:buttonB; return view autorelease; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 50; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } If you like I can share a demo project so you have a working example!

It should work with autoresizingmasks, I've done it before but it's important to set the with of your view correctly and add the correct sizingmasks. Some sample code to show how it works. This creates two buttons resizing whem you rotate.

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = UIView alloc initWithFrame:CGRectMake(0, 0, tableView.frame.size. Width, 50); view. BackgroundColor = UIColor redColor; UIButton *buttonA = UIButton buttonWithType:UIButtonTypeRoundedRect; buttonA.

Frame = CGRectMake(20, 5, 125, 40); buttonA setTitle:@"ButtonA" forState:UIControlStateNormal; buttonA. AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; view addSubview:buttonA; UIButton *buttonB = UIButton buttonWithType:UIButtonTypeRoundedRect; buttonB. Frame = CGRectMake(175, 5, 125, 40); buttonB setTitle:@"ButtonB" forState:UIControlStateNormal; buttonB.

AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; view addSubview:buttonB; return view autorelease; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 50; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } If you like I can share a demo project so you have a working example!

Looking at your code I noticed what my problem was...I hadn't set the frame of the buttons' superview...that's why my autoresizing masks weren't working. – akaru May 25 at 4:07.

Please use 2 frames for button one for landscape mode and another for portrait mode..this will work out..so when orientatin changes check whetehr its landscape or portrait and assign frame for it...check mode here willrotatetointerfaceorientation.

Thanks. But there should be a way for the table to take care of it I would think. – akaru May 19 at 6:03 nope..Table won't do it.. – Krishnabhadra May 24 at 5:25.

Best i've come up with is, use one button and one cell in its own section, then each will resize appropriately.

I do something very similar to yours except I only have one button. The uiview that you are returning should be the same width as the tableView itself. CGFloat footerWidth = mainTableView.frame.size.

Width; CGRect frameTableFooter = CGRectMake(0.0, 0.0, footerWidth, 60.0); viewForTableFooter. Frame = frameTableFooter; // buttons addition mainTableView. TableFooterView = viewForTableFooter.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions