Mohanraj S K
Mohanraj S K

Reputation: 657

IOS Tableview support all screens and Landscape screen

I Was create a UIViewControler in storyboard or XIB with autolayout.

When i add UITableView into the view controller it does not support all screens properly even not support to portrait/landscape screens too.

I Have attached a screen of my story board.

enter image description here

I am a Beginner for iOS , so i dont know hoe to set constraints.

Please Some one suggest a best tutorial to done this or provide a simple sample application.

FYI: I am using Xcode 6.1 and Objective-C

Thank you!

Upvotes: 3

Views: 397

Answers (1)

mbm29414
mbm29414

Reputation: 11598

It sounds like you're having trouble with adding constraints to a UIViewController.

Here is a good primer on AutoLayout on Ray Wenderlich's site. It's a good way to get your feet wet with AutoLayout in Interface Builder.

Once you do that, consider reading this article about why to not use Interface Builder. I was finally convinced by this article to go the pure-code route, and I've enjoyed the results.

Anyway, for your particular example, here are some screen shots to add the constraints to your UITableView:

  1. When you add the UITableView to your UIViewController, you probably lined it up so that all edges between it and its containing view matched up. In that case, when you click the "TIE Fighter" button (really called the "Pin" button), you should see the following: enter image description here

  2. At this point, you simply need to click the 4 "struts" to add those constraints to your UITableView. When you do that, they'll turn from light gray to red, as seen here: enter image description here

  3. At that point, simply click the "Add 4 Constraints" button to finish the job. Your UITableView should now be "pinned" to all 4 edges, causing it to resize automatically during rotation.

Upvotes: 2

Related Questions