UIView in UITableview, working with 3,5 inch and 4inch - ios

I'm trying to display a UIView inside a UITableview. This view must recover the whole UITableview during the process.
My app has the following layout:
As you see, I use a storyboard for my app. But since I have several tabs, with one tableview per tab, I have decided to use a nib file for this single view, and display it programmatically over each UITableview.
The main problem is that I don't know how to display it correctly for 3,5 inch AND 4 inch devices.
I would like to have this render, regardless of the device:
The view should be under the top bar, and over the bottom bar.
But else is too short for 4 inch, else is too big 3,5 inch (and my view is no longer centered).
I have been playing with constraints for the past 2 hours, searching on google, and I have not found the correct way to do what I want to do...
I can of course do it programmatically and check the content size and apply it to my view, but can I do it without this using autolayout?
Thanks in advance.
Edit here are my constraints:
(Two tries)

Related

Table view custom cell not responding according to constraints

I am designing a table view in which I have a custom cell in which I am trying to design a few views and sub views. I have placed my views as per the following hierarchy and constraints -
And here is my main story board -
I have given my table view cell's content view as orange colour and I have placed a view with yellow colour. I have pinged it to the content view of the cell. My storyboard is of the size 600*600 freeform(Size class - wAny hAny). When I run my app in ipad, it keeps a space as shown below between the cell's content view and its subview even on pinning the subview to all sides of content view-
So,what might be my problem and what mistake am I making? Thanks.
I think the problem is because of the sizing classes (like in the image).
if your app is universal (for both iPhone and iPad) make sure you choose it like the screenshot (w Any, h Any).
Please let me know the current settings.
Update
After sending me the storyboard. I have used it as it is in a new project. and that's how it looks in both iPhone and iPad
It looks fine in both of them. my best guess is it's a problem of the
preview only(which doesn't matter).
If you change the scene size from iPhone 4 inch to inferred
it solve the problem in the preview as well.

How can I change the size of UI Collection View cells depending on whether it is iPhone or iPad

After creating a universal app on Xcode 6, I have managed to create a UI collection view which displays 2 cells in the width of an iPhone. However when viewed on iPad, it shows 4 cells with lots of padding around the cells.
How can i change the size of cells on an iPad so that 3 cells are shown with minimal padding. I want to leave the iPhone size alone.
So far i have used the storyboard to set the cell size. I have a added a custom cell size of 158pts by 158pts which works perfectly with iPhones. I cannot find this code in the Objective C code. How can I set an individual different size for iPad.
This is what it looks like on iPhone.
https://www.dropbox.com/s/md1sn4z3k78i5s1/iphone.png
and this is what it currently looks like on iPad. The wrong way.
https://www.dropbox.com/s/0x2n9i8v6gvlfnc/ipad.png
I want to get rid of the Grey padding and increase the cell sizes so there are only 3 cells with the same padding as on the iPhone version.
I am a real beginner so any help is much appreciated.
I am answering my own post as I believe that the only way to do this is to use a standard ViewController and place a UICollectionView on top. This way you can add different UICollectionViews for the different Size Classes on Xcode 6.
At this point you can set different sizes for cells on iPad size classes to iPhones ones.
There maybe an easier way to use a UICollectionViewController but i am unaware of it, please let me know below.
EDIT
I have since found out this can be completed using the UICollectionViewController by using constraints and by increasing the cell when used on iPads by code.

iOS: autolayout for multiple button

In my app I have a view for 4 inch screens in this way:
And then I want to reduce the size of my buttons when the app is running on an iPhone with a 3.5 inch screen, so I set my layout in this way:
but finally I obtain a view in this way
In this way the size of my button are ok but they are not aligned, so in this situation, what's the way to have aligned buttons?
thanks
Hi as per your question i've created demo similar to the layout for which you need the controls need to set. I've added images for single control and made video this using multiple controls to set the layout which you retrying to set.
link: https://www.youtube.com/watch?v=Nl2iMF0yKW8&list=PLXCowKcXAVgrxHKLWTa4HxNPrSmTj3D-_
Hope this will solve your issue.
I may not comment till I 50 posts, so here is the link. I had like the same problem some days ago. Just put all those in a parent view and center the parent view.
Link to my question/answer:
Top constraint won't get less with auto-layout

optimizing my app to iPhone 3.5 inch screens

I have made an app and it works really great on iPhone simulator 4 inch screen.
But, when I run it on the iPhone 3.5 inch screen, it cuts the bottom of my app
How can I optimize my app to the 3.5 inch screens?
(note :I am using storyboards)
Open your storyboard, then select one of the view controllers. Change the size of the screen to 3.5" as shown here:
Make sure your views are laid out correctly. You may either use Auto Layout or, if you're not using it, check the view sizes, and the springs and struts:
Here, you want to make sure that you don't hardcode the view height to 4", or doing anything similar. After you make the fixes, you can switch back to the 4" size, to make sure the views are still laid out. Repeat for all your view controllers in your storyboard, until done.
If your code updates the UI (e.g. by adding/positioning/animating views), you also need to make sure you're not hardcoding any view's frame with the assumption that the screen is 4".
First option is to use autolayouts.
Second option is to set your views scale properly.
by clicking on a button i selected, you can see how will your layout look on different screen sizes
Now, you select a view you want to set-up, and play with this option here, marked on the picture below

Developing on an iPod iTouch - UIView Issues

So I've been using this site for a lot of my questions. I'm very good with Googling problems and debugging even the worst error code, but this is something rather basic that I'm not able to figure out.
My UIView compared to what I actually see on the iTouch has always been a bit different. I'm not sure if this is xCode's IB just having larger graphics for its buttons, but in general there is this 20px height difference, to the point where if I set a button at the bottom of the UIView, it gets cut off. (I thought it was supposed to be 320x460..)
Normally I shrug this off because it hasn't been an issue till I've started to put scrolling into place with the login screen. xCode claims my view is 320x548, my app says its 320x480. If I resize my scroll size to 320x480, the view shrinks on the iTouch, leaving a large gap.
I have been using UIViews in the IB rather then a ViewController because I'm subviewing mixed with some nav control.
Is there something that I'm doing wrong?
http://oi49.tinypic.com/rrnjit.jpg (when first loading)
http://oi50.tinypic.com/j8matu.jpg (scrolling down about 20 px..)
You need to make correct use of springs and struts or Auto Layout. You are probably designing your app for the 4 inch screen - in your Storyboard, there is an option to see how it would look on a 3:5 inch screen. Press that.
For more info, Google Auto Layout.

Resources