Table View resizing issue - ios

I am developing an app that will have a small login screen. I used a table view that calls separate nib files. Each nib file is set to have a 100 row height and the entire table (3 rows) has a a height of 300. It seems to not work well depending on the size of the iPhone. In the following screenshot you can see there is still white space added after the last row. How could i adjust the table view as a whole to be the same size as all 3 of the table view cells? I could adjust it so it works for this one iPhone screen but it will not look good for others. I am using swift to code if that helps.
Thanks!

You can achieve this by getting the Iphone models screen size and divide in to / 3. You use like this in the view controller :-
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = self.view.frame.height / 3
}

Related

Swift: Make it obvious that a table view is scrollable

Strange question really but here goes.
I have a table view with some custom cells. On larger devices they all fit and it looks great.
However on the smaller devices like iPhone 4 due to the other content on the page the table view shrinks and therefore not all of its cells are in view.
The problem:
Without actually physically scrolling the view it would be impossible to tell that there were any other cells.
Is there a way around this?
Thanks.
You could use this:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.tableView.flashScrollIndicators()
}
You could use the heightForRowAtIndexPath to calculate a height for the cells so that the last cell is not visible fully. Seeing a cell cut off half way is a good indication for the user to feel that there is more content beneath.
I added this code:
tableView.contentOffset = CGPoint(x: 0, y: 200)
The first card and the last cart are cut-off which gives an impression that you need to scroll.

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.

Universal App: Getting Table View To Fill Whole Screen

I have two table views, both without table view controllers, I have a view controller that's taking care of both of them.
The problem is that I'm getting weird scalings of the tables on different devices. It seems to be almost perfect on the iPhone 4 simulator. The table looks almost ridiculous on any iPad simulator.
My Table Views View settings look like this:
scale to fill
I tried changing the launch images to see if that would have any impact on scaling/zooming/etc, but that didn't really seem to change anything.
How Can I Get My Table Views To Automatically Fill The Whole Screen On A Universal App?
edit:
alignment constraints are disabled:
If you are using the autolayout give constaints to table view as leading, trailing, top & bottom. It will change its size as per device.
You need to set the frame of the table view to occupy the whole screen
UITableView tableView = [[UITableView alloc] initWithFrame:self.view.bounds];

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.

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

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)

Resources