What are the best practices in building user interface with Xcode? - ios

I am designing a simple user interface for an app using Xcode and Auto Layout. I have a view controller with three basic outlets: a static image view, a label and a button. You can see it in the picture shown below.
As you can see, I'd like to have the image view horizontally and vertically centered in the view controller, the label just below it and the button somewhere in between the label and the Bottom Layout Guide.
The problem is that I am experiencing some appearance problem with the iPhone 6 I am using for testing. The interface items are not nicely centered as they are supposed to be, as you can see from this screenshot.
I am not asking for the solution to this problem, though. I would rather know whether there are best practices to design a good user interface. For example, is there some way to temporarily hide the label and the button from the view controller to focus only on the debugging of the image view without having to remove and redesign them again?

Select the label you want to hide,then uncheck the checkbox installed

You can simply set its alpha to zero .

Related

storyboard constraints (Xcode)

I'm new to programming and I'm trying to work with Xcode. I have no experience. I'm trying to make an app with Xcode. I'm done with the code, the only issue i have is with the storyboard constraints. I need some one who can help me to set them up.
So, i have 28 buttons as you can see in the picture, I want to keep the size of 65x65 pixels. that means that the distance between them should vary in different device sizes(4inch, 4.7inch and 5.5inch). i also should mention that i want it to be only in portrait view and only for iPhone.i hope someone can help because I'm to noob for this, I've searched a lot on the internet but I'm not able to do it.
UIStackView (iOS 9+)
UIStackView was introduced in iOS 9, which is very useful in your case.
Edit: Before getting started, make sure to have size classes to be w Any, h Any, this will make thing easier.
To use this, search UIStackView in your utility panel.
Drag an drop a Vertical Stack View on the view of your view controller and set the constraints so it spans the whole screen.
Select the stack view we just placed and set the distribution to Fill Equally.
Drag and drop a Horizontal Stack View onto the vertical one.
Select the horizontal one and set the distribution to Fill Equally.
Place your buttons in the Horizontal Stack View.
Copy and paste the horizontal stack view multiple times based on number of rows you want.
That's it.
You can control the buttons' background images to make it smaller (65px), or you can place a view as its' parent then align horizontally/vertically to place it to the center, like this:
Orientation
If you'd like to lock the orientation throughout the app, go to the settings of your project.
Sample project
I made a sample project for this question, you can check it out here: https://github.com/cyhsutw/UIStackView-example

StoryBoard Different screen sizes iOS

I'm trying to make an app. I prepared the ui with sketch app.And I export the ui , it is like this:
I add some text field and button to View
But when I use Auto Layout and constraints buttons and text fields are going to another place.I need the use them like in the picture.What should I do ? Do you have any suggestion ?
Thank You
Notice the red arrow at the top right of your second screen shot. That is telling you that your constraints are faulty. Until you fix them, you will not see your interface widgets in the desired locations.
In general, as long as you see a red or yellow arrow in that spot, you need to work on your layout some more. Do not attempt to run a project when Interface Builder shows you that red or yellow arrow; your results will be disappointing, to say the least.

Extra space on top and bottom of Init View Controller

I have a swift app I have been working on for some time now. I noticed that my init view controller has extra space at the top and the bottom of the view, so much that it allows me to pull up and down on the first view and let go and have it spring back into where it was. I removed all my constraints thinking I had an issue with them, but it's still done the same thing. The size class is set to any any, and all my graphic fit inside the view, yet I still an able to pull up and down.
I also made sure my view, wasn't a scroll view, it's not.
I looked around for similar issues, but couldn't find anything like this.
Thanks for the help!
Here is what my view looks like in IB
When I run the app.
Showing the amount I am able to pull it down from the top.
If you remove all of your constraints, and the storyboard is set to use auto layout, it usually won't show up correctly, as you have seen. You will have to add the constraints to each element in your view controller. To do that, you can control click on each and drag it where you want to connect a constraint. Or, use the pin and align buttons in the bottom right corner of the storyboard view.
There is a good tutorial from apple that I suggest you read. It will help you with the basics of using auto layout. Another option would be to not use auto layout. To turn it off in the Storyboard, go to the file inspector and uncheck the box "Use Auto Layout".

UIViewController completely out of place on the screen

I am putting together a sample iPhone app for practice. It is a drill-down interface with doctors who have patients who have prescriptions and visits using Core Data and a story board.
Everything was going great until I started on the Edit/View doctor screen. Because this screen is triggered by a button in the UITableViewCell, it seemed that there was no way to create a segue on the story board to an edit/view screen because the buttons in the cells are dynamically created.
I decided to make a separate UIViewController custom class and I let Xcode generate the XIB for me to make sure I did not mess up anything. I presented the edit/view view controller by pushing onto the navigation controller. The problem is that the contents of the edit/view screen were nearly completely off the screen. With my first attempt, a navigation bar I put at the top appeared at the very bottom of the screen in the simulator with all of the rest of the text fields and labels not showing at all.
I then created another view controller with xib, specifying iPhone only and simply put a label with "Hello" in the center of the view. When I ran the simulator, "Hello" was centered vertically, but was all the way to the right of the screen with only "He" showing. I tried played with anything I could find to play with, but nothing fixes it. I am not trying to do anything unusual. I want to do everything in the usual accepted way.
Also, it seems like Interface Builder makes the views look like big square iPad screens even when I have specified iPhone. I did check the frame dimensions and it was wxh = 600x600.
Thank you for your help.
It occurred to me to search for 600x600 and it seems that this is the new UIView that Interface Builder provides by default. Because there are many screen sizes, Constraints are apparently mandatory now.
My edit/view form was completely fixed by viewing the XIB and going to:
Editor->Resolve Auto Layout Issues->Add Missing Constraints.

Custom UITableViewCell elements getting cut off in the Interface Builder

I'm just getting started with iOS development. I am trying to make a custom UITableViewCell for an iPad-only app.
I am using XCode 4.2 and the latest iOS 5 Beta.
When I'm trying to build my interface, I can't place an elements or make any elements wider than about half of the cell size that's displayed. In the screenshot attached, I want to place the "Name" label on the far right side and stretch the progress bar to the far right side as well. However, when I stretch the progress bar out any further, it just gets cut off.
I'm sure I'm missing something...any ideas?
If it is allowing you to stretch the progress bar the entire length and then cuts it off after you release it, then there is probably another object (i.e. custom button, image view, etc) on the right portion of your cell that is higher on the view stack.
Check in the Objects section of Interface Builder to see if that is the case. Then you can adjust accordingly.
I'll like to make a little guess here...does it have to do with the orientation of landscape/portrait? It looks like the cell is landscape but the view is only for portrait...
check every controller with background color property. set the different color for every one. Might be it's overlapped one view over second view.

Resources