Swift 4/Xcode 9 - UITableView custom cell getting cut off on the right - swift

I'm having trouble setting constraints on a tableView that I've inserted into my View Controller. It's occupying around half of the view and despite pinning it to the sides of the view, it seems to maintain the same size dimensions when I switch to a smaller iPhone causing it to overlap on the right side. I'm using a custom cell with 2 labels. I've tried the suggestions in this thread with a similar question: AutoLayout labels getting cut off on right side of screen but haven't had any success.
Here is how it looks when being viewed on the iPhone 8 plus
and here's how it looks on the iPhone SE.
Here are the constraints that I set for the tableview.

Related

Why Xcode Storyboard preview and emulator button texts are not compatible?

I am trying to drag and drop buttons to the storyboard. The buttons seem good in my storyboard and preview like the following;
However, when I run the simulator, the button texts seem like the following;
Why the buttons are not shown to fit in the buttons of the simulator and how can I fix this?
Note: Preview and device types are iPhone13 Pro.
The iOS 15 / Xcode 13 style buttons are highly dependent on auto-layout.
Based on your screen-shots, it doesn't look like you've given the buttons any constraints.
You do NOT need to set widths or heights, but you DO want to set at least horizontal and vertical position constraints.
So, constrain all 4 of your buttons centered horizontally, and constrain:
First button Top to view Top (safe area)
Second button Top to First button Bottom
Third button Top to Second button Bottom
Fourth button Top to Third button Bottom
Then you should see them laid-out correctly at run-time.
I think it's because of the auto layout constraints. I am not very familiar with storyboards, if you don't set width of the view component, it seems fine on the storyboard but when compiling the view it actually has default size.
Try to set some constraints for width. Maybe it would help.
The first thing you need to do is to create identical buttons with identical size and with identical font size.
As you can see in your project, the buttons have different sizes, but the text is the same size in all buttons.
To make it faster - you can create one button and make a copy with option + drag’and’drop…
Then, you can put them in a Stack View. So, it will be easier for you to work with them in the future.
Select all buttons and make a Stack View...
https://i.stack.imgur.com/QLTJP.png
https://i.stack.imgur.com/OlOia.png
After that, resize your Stack View like you want.
Then, tap on a Stack View and clear the constraints.
https://i.stack.imgur.com/1pMT8.png
Fix the dimensions like this. But, without “Constrain to mergins”.
https://i.stack.imgur.com/8HKKF
After that, make for the Stack View - horizontally and vertically position in your storyboard.
https://i.stack.imgur.com/a29wL.png
The result is…
https://i.stack.imgur.com/mvQjg.png
Hope it’s break your problem! :)

Subviews of ViewControllers shifted to the left in iOS 7 / XCode 5.0

I've got a project in XCode 5.0 that I ported from XCode 4. Most everything in XCode 5.0 makes sense, but I can't seem to figure out why some subviews of my view controllers are shifted to the left when I compile and run the app.
1.) I have a tableview inside of a view in a view controller. The containing view is freeform portrait with no status bars. It is 520 by 520 in interface builder, centered. When I compile the app, the table view isn't wide enough to fill the width of the view that contains it. The tableview appears to be shifted 30 pixels to the left.
2.) I have disabled auto layout. I hate auto layout for a number of reasons, mostly because I really like to tell Interface builder exactly where things need to go in specific screen configurations. (Please don't preach I just hate relative layout schemes and am willing to do extra work to avoid them).
Does anybody know what might cause the widths of subviews to change in XCode 5.0 ? I have temporarily set the frame manually in the code, but it's really weird because I need to specify a width that is approximately 20 - 30 pixels wider than what I originally had.
Any idea where this difference is coming from?

UITableView: table view scrolling makes images disappear

I am working with one iOS application it has two tables placed side by side, each table view holds images. Both table views having the auto scrolling and manual scrolling functionality. By default both tableviews in auto scrolling mode, but the problem is when user did manual scrolling images in table view become disappear (loading images very lately) and its happening when table view state is moving from auto scrolling to manual scrolling and manual scrolling to auto scrolling. currently I am using static images only (not dynamic and not from server). In future i have to use with dynamic data(images) coming from server.
Any ideas to fix this issue that will be very helpful to me.
Check the size of your UITableViewCells and all their subviews. Sometimes (at least for me) the sizes will be at 0 and then when that frame (which is 0 points high) goes off the screen, the image will disappear.

UITableView scrolls choppy when the UITableViewCell is big

First, I know there are a few answers here on S.O. that addresses the choppy uitableview issue.
Some of them i applied in my code (namely the cell.layer.shouldRasterize = TRUE in particular as well as the cell queue caching thing).
My choppiness is observed to be due to large cell rows (70 pixels height).
If I change the row height to be 20, then it scrolls smooth as butter.
But 30 and above, it gets choppy, especially when i "pull" and "let go" of the table so that it bounces back into place.
One thing that i am NOT doing is flattening the view (I am using the cell's Xib).
Would doing away with the xib design view give me the performance boost that I need?
Also, any ideas why a 30+ pixel height cell row is causing such a drastic difference compared to the smooth-as-butter 20 pixel height?
Note: Even if i make everything in the cell xib to be hidden, i still get choppiness at 70 pixel height.
Check out the example from Apple - TableViewSuite. Look at the fifth example which shows hot to make a very fast cell with images and labels. Also note that cells created using xibs are much slower. So avoid subviews and perform custom drawing in drawRect method. Everything is shown in the apples example:
http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html

Multiple UITextFields grouped together like a UITableView section

I'm looking for a clean way to implement a login screen in my iPhone application. I'd like it to appear as a grouped UITableView section with rounded corners and a separator line below between rows (like e.g. the sections in the Settings app). However, I'd like to give it a slightly smaller cornerRadius than the default setting of a UITableView section.
Another thing I'd like to do in that screen is to add a "register as new user" button which causes the whole screen to slide up, presenting the registration screen. There will be a background image that spans both screens vertically and should slide up with together with the content.
I was first thinking to just make a UITableView, set it to grouped, add two sections (one for login and one for registration), add some space between them and disable manual scrolling on the UITableView. However, I found that putting a background image correctly behind a UITableView and to make that scroll together with its content is a bit tricky..
Perhaps I shouldn't be using a UITableView and just write some code myself that can wrap multiple views (each containing a label and a textfield) together into something that appears like a UITableView section? I've been searching around but surprisingly it appears that not too many others are trying to solve this same problem.
Any suggestions would be very welcome!
Sounds like a UITableView is overkill for what you need. I would just create a custom UIViewController and have it handle the layout of all of your subviews as well as any animation you desire.
Just have the parent view take up more space than the device's screen. Then, when you want everything to slide up, animate a change to that view's frame property.