How to Make a Uitableview in Interface Builder Compatible with a 4 Inch Iphone

How to make a UIButton in interface builder compatible with a 4 inch iPhone

Solved the problem.

Just had to look in to Auto Layouts and Constraints.

This was the helpful link for me.

Hope it helps someone else too!! :)

How can I expand UITableView to fill full screen on iPhone 5 using Interface Builder?

The problem was resolved by setting the AutoLayout property on the TableView. Once I did this the table resized accordingly. I also subsequently discover that I could do take care of resizing by setting the AutoSizing mask.

Support of iPhone 4-inch screen by storyboard

To enable your apps to work with iPhone 5, I suggest you to do two things.

First you need to add a retina version of the launcher image. It should be named Default-568h@2x.png.

And second use Auto Layout and make sure you have your autoresizing mask set up correctly for all your views.

Support of iPhone 4-inch screen by storyboard

To enable your apps to work with iPhone 5, I suggest you to do two things.

First you need to add a retina version of the launcher image. It should be named Default-568h@2x.png.

And second use Auto Layout and make sure you have your autoresizing mask set up correctly for all your views.

Interface Builder locking object to screen edges

You need to attach the UITableView to all edges of the parent UIView, and then the UITableView will expand or shrink to fill the UIView on the device. This will make it appear to be the proper size on all iDevices, including iPad. As pictured in the screenshot below, you can just tap all the dashed red guides, making sure the margins are set to 0 (touch the sides):

AutoLayout via IB for a UITableView touching all sides of the parent view

You could also Ctrl + drag left, drag right, drag up, and drag down on the UITableView choosing "Leading Space to Container", "Trailing Space to Container," "Top Space to Top Layout Guide", and "Bottom Space to Bottom Layout" respectively.

Alternatively, you could use the Visual Format Language (VFL) (code for a UIViewController below assumes your UITableView is an auto-@synthesized @property named tableView):

/* Turn off springs/structs */
self.tableView.translatesAutoresizingMaskIntoConstraints = NO;

/* Leading and trailing constraints */
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_tableView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_tableView)]];
/* Top and bottom constraints */
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_tableView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_tableView)]];

...or if you really like to be explicit (and like typing):

/* Leading constaint (could use NSLayoutAttributeLeft here as well) */
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0]];
/* Trailing constraint (could use NSLayoutAttributeRight here as well) */
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]];
/* Top constraint */
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
/* Bottom constraint */
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];

The important thing with all of this is that the UITableView is a child of the view of the UIViewController (it most likely is). view will fill the screen as expected by default, and with all of the methods above, you're asking the layout to hold tight against the edges of that maximized view.



Related Topics



Leave a reply



Submit