Home > DeveloperSection > Forums > How to use table view controller with small sized in iOS?
naomi burke
naomi burke

Total Post:28

Points:196
Posted on    December-09-2015 11:02 PM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 213  View(s)
Rate this:

I have created an app using UITableViewController, its method initWithStyle: automatically creates the underlying UITableView with- according to the documentation - "the correct dimensions".

Now, my problem is that these "correct dimensions" seem 320 x 460 (default screen size of iPhone), but I'm pushing this TableView / Controller pair into a UINavigationController which is itself contained in a UIView, which itself is about half the height of the screen.

Now, my question arises that what is the proper way to set a table view controller to resize its component UITableView to a specified rectangle?



Tarun Kumar

Total Post:210

Points:1614
Supported
Posted on    December-10-2015 10:20 PM

I also face the same problem as your's. but I solve it.
Use code like this:

-(void)loadView{
  [self setView:[[[UIView alloc] initWithFrame:CGRectZero] autorelease]];
  [[self view] setAutoresizesSubviews:NO];

  [self setResultsTable:[[DataViewController alloc] initWithNibName:nil bundle:nil]];
  [[resultsTable view] setFrame:CGRectMake(0,45, 320, 200)];
}

above code is written under the parent controller.


Don't want to miss updates? Please click the below button!

Follow MindStick