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):
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
Coreanimation - Opacity Fade in and Out Animation Not Working
Lock iOS App in Single App Mode Programmatically
Autolayout Aspect Ratio for Uiimageview/Uiview
Change the Alpha Value of the Navigation Bar
Will Appstore Reviewers Allow Us to Use Dynamic Library in iOS8
How to Receive Push Notifications of an Other App
Collectionview with the Horizontal Scroll with Mulitple Section
Xcode 11.4. Navigation's Title Color Gone Black from Storyboard
How to Animate a Uiview with Constraints in Swift
It Gives Errors When Using Swift Static Library with Objective-C Project
Google Analytics 3.08 iOS Idfa Class Missing, Won't Collect Idfa
Gem Native Extension Error While Installing Cocoapods
Google Objective-C API 'Gtl' with Swift
Add a Scrollview to Existing View
Reload Section Without Reloading Section Header
How to Add a Credit/Debit Card into Apple Wallet from the iOS App