Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange three20's TTTableViewController frame properties

I am adding a TTTableViewController into an existing UIViewController, one strange thing I found is that the frame properties of the initialized TTTableViewController are wired, e.g. in a iOS layout.

I have:

  1. UIStatusBar
  2. UINavigationController
  3. UIViewController
  4. UITabBar

In order to set the TTTableViewController fill in all the remaining space I need to set the height to 460 instead of 367. (367 = 480-20-44-49)

e.g.

self.tableViewController.view.frame = CGRectMake(0, 0, 320, 460.0f);

instead of

self.tableViewController.view.frame = CGRectMake(0, 0, 320, 367.0f);

Why is it so?

*Edit for clarification: I mean TTTableViewController on the top of TTViewController (using [self.view addSubview:self.tableViewController.view];), and I need to set the self.tableViewController.view.frame = CGRectMake(0, 0, 320, 460.0f); instead of 367

like image 290
Ryan Avatar asked Sep 12 '12 17:09

Ryan


3 Answers

It depends on when you are setting the frame, I think. I'm pretty sure when you set the frame in viewDidLoad, for example, you'll be setting it before the status bar and other things are taken into account. There might be other cases like this. If you set it to 320:460, it'll be resized to take into account the status bar and other stuff afterwards, making it fill in the rest of the screen. If you set it to 320:367 because you've already taken into account that stuff, it'll get resized again and squished (basically scaled down twice), making it only fill part of the screen. If you're using viewDidLoad you could try sticking it in another method (maybe viewWillAppear?) or just keep using 320:460.

It'd be nice to know when you set the frame, exactly. Also keep in mind that I could be way off. My mind's feeling a little fuzzy right now.

like image 150
Metabble Avatar answered Oct 16 '22 09:10

Metabble


As per my understanding, only the size of your status bar is deducted i.e. 480-20 = 460. actually status bar is 22 pts but its approx.

Its just like when you add a viewcontroller to your navigation controller or your tab bar controller the size is auto rendered. So same is the case here, the three20 automatically adjusts the size of the view and if you try to set it to something smaller then that it behaves differently.

Its a nice question though. Happy Coding. Cheers!!

like image 40
Apple_iOS0304 Avatar answered Oct 16 '22 10:10

Apple_iOS0304


I wouldn't add a view of a different view controller into the main view of your current view.

You should present the TTTableViewController using the controller's present / dismiss functions. if you don't want to include the slide up effect, so the users won't see that it's a "different screen", use the boolean flag when you present the controller.

   [self presentModalViewController:vc animated:NO];

Alternatively, use a TTTableView without the controller:

tableView = [[TTTableView alloc] initWithFrame:CGRectMake(0, kScrollViewHeight + kSignupLabelHeight, 320, kTableViewHeight) style:UITableViewStyleGrouped];
[tableView setBackgroundColor:[UIColor clearColor]];

tableView.delegate = self;
tableView.dataSource = [TTSectionedDataSource dataSourceWithObjects:
                                 @"",
                                 [TTTableTextItem itemWithText:@"Sign Up" URL:@"tt://signupController"],
                                 nil];
[self.view addSubview:tableView];
like image 1
aporat Avatar answered Oct 16 '22 11:10

aporat