iOS 7 keep buttons at bottom in 3.5inch and 4inch - ios

I haven't done iOS development in a while (since Xcode 4 and iOS 5). And I have a very noobish question:
How can I keep buttons at the bottom of a storyboard viewcontroller on both 3.5inch and 4 inch devices? Previously I could use 'origin' or something similar in the right side panel.

A quick solution, especially if you don't need to deal with rotation of elements much is to add some basic auto layout constraints to your view.
Once you have your button set in place in your view where you want it to stay in the view, select your View in the Storyboard and then from the Menu Select Editor -> Resolve Auto Layout Constraints -> Add Missing Constraints in View.
Simply doing that will give you what you want. Make sure you have auto layout enabled for your storyboard.

set autoresizing mask as shown in image to keep button at buttom in both 3.5 and 4.

i think you are using autolayout so apply first approach
with AutoLayout. add constrains for your widgets
without AutoLayout

Related

Issue displaying uitableview in UIViewController - Not aligned

I dragged a uitableview component to my UIViewController in the Storyboard.
It appears as
Then when I ran the application, there's a space on the side. How to prevent this?
Note: Initially this application was enabled autoLayout, and I removed it later on. Hope there's no effect for this error.
Add constraints on your tableview.
If you don't know how to, here is a simple step by step :
Right clic or ctrl+drag the tableview (on the left side list) to
View.
Select Top space to top layout guide Repeat with Bottom
space to bottom layout guide
Repeat with Leading space to
container margin
Repeat with Trailing space to container margin
That should fix your issues.
The answer on this link will surely help you.
https://stackoverflow.com/a/26708486/3396270
Though its Table view in your case you can use it with all the components by changing the settings as per their requirements.
Check your screen size in Storyboard:
And make sure you are running the application on same size of Simulator as in your storyboard.
If you uncheck the Translucent property of your Navigation Bar, it's going to fix it.
If you are not using AutoLayout then just write this code in your viewDidLoad Method
[tableView setAutoresizingMask:UIViewAutoresizingMaskFlexibleWidth | UIViewAutoresizingMaskFlexibleHeight];
You could also set the AutoresizingMask from your nib file.
What version of the xcode are you using? If it's okay with 5s and not okay with 6 and 6+ then you should change the size of the table manually or use autolayout. Storyboard which you'v used should have optimised for devices below 6. I you're using #3x image for splash screen then your app supports 6 and 6+ but it uses the same table size as what it is designed for 5s device size on simulator.
Solutions-
Use auto layout so this will solve the issue itself.
Else create outlet for table and changes it size according to the device width and height.
I have released an app using the above 2 solutions and its in the store now.

UIView Doesn't allow swipe down to see rest of the screen

I build a view that has contents which exceed the height of the iphone 6 screen vertically.
To test that out, I've set a specific height for my image (600pts) to guarantee that the whole content wouldn't fit on the screen of an iphone 6 and that you should swipe down to see the rest (the label "BYE").
However, when I run the simulator, I cannot swipe down to see the rest of the screen.
I've used Autolayout constraint and set a margin top/bottom between each components and the superview (I don't have any autolayout constraints issues/warning).
Here's the screenshot of the storyboard of my UIViewController:
Here's when I run the simulator, I cannot see the Label "BYE"(which is normal) but I cannot swipe down to see it.
I am using Xcode 6.1 and Swift.
Any suggestion and explanations?
Thanks a lot!
I have redone your screen and here are the steps. The reason for your issue is not setting proper constraints in autolayout. First you need to choose AnyWidth AnyHeight in Xcode which is in bottom of the storyboard.
Here is the screenshots of View in StoryBoard and its constraints
Constraints
Final Result in Simulator
Setting the constraint properly will work for you. Let me know if you have any issues in doing so. Sorry for the image i used its low quality one and its just for test.
EDIT
In Storyboard if you see the bottom of the screen you will see below image. In center of that image there is wAnyhAny.
you need add constraint to thoes components!
Otherwise, some components will be placed out of the screen!
You can learn how to use Autolayout from here
![enter image description here][1]At right bottom of storyboard in xcode you will see triangel Resolve autolayout isuue select in Reset to suggested constraint.

iOS orientation change resizing

I have read a lot of SO question about this already but nothing seems to work in my case. Simply when you add a UITableView and you test it and rotate the screen it will keep the width of the portrait orientation.
How can I make it so that it will always fill the screen's width for any screen size?
EDIT : My size inspector
Use the Autosizing feature in Storyboard for your UITableView. How to set it:
1.Select your UITableView.
2.Open the right pane -> Size Inspector:
3.Scroll down to the View section, here you'll see the Autosizing menu:
Don;t forget to disable Autolayout feature:
You're using AutoLayout in your XIB, so the AutoResizingMask stuff isn't your best route to success. You need to set the autolayout constraints on your TableView so that there is a 0 px gap between the leading (left) and trailing (right) sides of the TableView and its superview.
You can see from your screenshot that you already have some constraints in place, but they're probably not correct. I suggest you start by resetting all the existing constraints: I find that's usually best when I've got confused about where I am with constraints.
Select the top level view in your XIB file
Select Editor -> Resolve Auto Layout Issues -> Clear All Constraints in View from the menu
Select your TableView
Select Editor -> Resolve Auto Layout Issues -> Reset to Suggested Constraints from the menu
If that does the trick for you, I'd advise that you spend some time getting familiar with AutoLayout and review the constraints generated: you can select and edit them in the size inspector. This is also a pretty good tutorial.
For custom views, I often add my constraints programmatically as it's really easy to keep track of them - they're much more visible than when they're built in IB. I use a set of categories, provided by another SO user, that you'll find here and they make the code very easy to read and maintain.

Auto Layout views inoperable in iOS 6

I'm using Auto Layout for an iPhone app to place a button footer bar at the bottom of the screen on both 3.5" and 4" iPhones. The bar is a UIView containing two UIButtons and a UIImageView.
I have a Vertical Space Constraint pinning the bottom space to the superview.
(Editor -> Pin -> Bottom Space to Superview)
It has an Equal relationship. Constant is 60, Standard is NO, Priority is 1000, and Placeholder is NO.
In iOS 7 it works exactly as expected. In iOS 6, it does not. The bar is not a consistent distance from the bottom when I switch between that view controller and its neighbors, and the buttons frequently do not work (they don't even highlight when I tap them). This is all in the simulator, I haven't tried hardware yet. The app is a legacy app, so all of the layout work is in xib files, not storyboards.
Do I need to do something different in iOS 6 to get Auto Layout to work? From what I read, it should be fully compatible with 6 & 7.
Some more information is needed to really get to the heart of the matter. Specifically how auto layout is being used to attach the bar to the bottom.
One thing that gets me over and over though, is remembering to set the translatesAutoResizingMasksIntoConstraints property to false on view(s) that utilize constraints.
Be sure to check the log output while debugging as that will indicate if you have any ambiguous or unsatisfiable constraints. At design time, XCode 4 IB will attempt to add any constraints that you are missing for you. XCode 5 IB will only tell you what you are missing and then at runtime try to add any missing constraints if it can.

Buttons well displayed in IB but not in simulator

I'm adjusting buttons like this in IB:
However, when running I have this(B is in above A) :
When I disable auto layout, I have the expected results, however, I'm having other problems with other views. Is there any solution other than disabling auto layout?
Thank you very much.
Your constraints are the problem. Try to get rid of constraints that are making the button aligned from the bottom. Then apply the 3.5 form factor in the IB to see if it works. Just ask if you need more clarification.
Edit: A tip is that if you can't delete the constraints from the menu, you can go to the document outline and manually delete it.
Check if Auto Layout is enabled.
If Interface Builder is using 3.5" layout, and your simulator is iPhone 5 ( 4" layout ), you have to adjust the Auto Layout constraints to fit the 4" layout.

Resources