Swift Custom TableViewCells only appearing in stack view - ios

I have a simple TableView with a custom cell that has two labels and an image. Everything is linked correctly between my custom cell class and the storyboard itself, but when things run on the simulator it just doesn't show up. Eventually I put them in a stack view just because, and it turned out to work. This makes no sense to me as why would a stack view make something appear but without it they don't even appear as the wrong size. Here are two pictures showing the cell with and without the stack view and what it looks like when executed.
Before
After
Not sure what the problem is or how to fix it.
The layout for my project is width-Any and height-Regular

Related

UIImageView Not Deleting From UITableView

I have created a UITableView with a cell inside. Inside this cell view, we have a Content View, and in that, I have subtitle text. This is all in the storyboard. I wanted to have an image right next to the cell, so I put an image and chose a picture.
The image turned out really small, and I couldn't even make it bigger - it was that small. So I put another image view that I created in the view and plopped it into the tableView. Then I try to delete the first tiny image view. It doesn't delete.
When I try to move it out of the Content View, it duplicates itself. When I try to drag it to the view and out of the Content View, it sends a duplicate version. So I tried to change the cell type from subtitle to custom, hoping that everything in the Content View would disappear and I can put it in again.
Then, Xcode crashed. I tried again with changing it to custom, but it crashed again. I didn't put the crash report because it is very long but tell me in the comments if I should put it, and I will edit this question to put it in. Tell me if there is any other information you need.
Thank you in advance!
UPDATE:
I deleted the whole cell. I realized that when putting a picture in the attributes inspector of the table view cell, it makes the picture either really big or really small. It doesn't allow me to resize the picture or move the picture without randomly duplicating it. Does someone know why this happens?
If you want to customise the size of your image, you can do so very easily by creating a UINIB file and then customising the look of your cell in the new file created. You can do so by creating a new cocoa touch class of type UITableViewCell and then select the create XIB file checkbox. Then you will see a similar to main.storyboard layout which works exactly like the main.storyboard and the difference is that it is specifically for the table cell. Make sure you register the UINIB with the table view so that you can control the data that shows up in your cell. I hope this helped!

Creating a menu in iOS

I'm currently creating an update of my iOS application and I'm a bit stuck. I've tried to googling around but cannot find a decent answer on this.
I've a menu which links to different views. And I'm not really sure if I've done it the best method.
I've created a view, and added the links into a stack view. Should I considering changing it all to a tableview? or a collection view? Or maybe there's another way?
The current look:
Should I change this to a tableview? collection view? or something else? Or just let it stay as it is?
If the number of items in your menu changes at runtime and is large, you should use a table view, because a table view is good for efficiently displaying a screen's worth of items from a large list of items.
If the contents of your menu is small (under maybe two screenfuls of items) and fixed at compile time and you are using a storyboard, then you could use a table view with static cells, if you can make it look the way you want.
If the contents of your menu is small, then you can use a stack view (inside a scroll view) if that is easier for you. There is no particular advantage to using a table view over a stack view to display a small amount of content, unless you need other features of the table view (like the ability to select/deselect rows).
Based on the screen shot you posted, I'd either use a table view with static cells (since the screen shot is from a storyboard) or a stack view, depending on whether I can get the appearance I want from a table view. If, as in the screen shot, the buttons must be centered vertically, I'd use a stack view, because it's easier to vertically center the content with a stack view.
Look, the fact of have many itens on your screen is clear on the mobile applications, to make it easy, we have collecions view like UITableView and UICollectionView. On the UITableView's case, this implements the scrolling and have methods do handle the operations' list, you can see the documentation to check these methods: https://developer.apple.com/documentation/uikit/uitableview.
Main reasons to use UITableView
Implements scroll behavior.
Independent of size screen you can access all itens.
Easy to detect interactions like tap on cell.
Easy to make changes, like insert and remove content.
The UITableView exists precisely to solve problems like you has.

UI elements not displaying where they actually are on storyboard in xcode

though the elements show, they don't show in the proper location
When I put UI elements in to the storyboard on this app that I'm working on they do not show up in the right location. I can edit them, move them, manipulate them... but all of it shows up lower than where they are actually located. then on this second viewcontroller that I have created, the header from the first viewcontroller is now showing up over there.
Not really sure if there is a way that I can reset the storyboards or get this to clean up at all.
thanks.
delete all your constraints first from the left hand side of the story board.
run the app and see how it looks
now, set contraints for each widget one by one properly and give it a try
The two buttons were in a stack view with constraints that were throwing them off. Once I removed the stack view and laid out the buttons without the extra view they worked perfectly.

UITableView Partially Blank in Storyboard

When trying to view a larger UITableView inside of a UIViewController in the storyboard, I can only see/edit the top most cells from the table. The moment I scroll further down the cells are all blank. This is purely for storyboard, the code works fine when running, but any cells in the storyboard that are further down a tableview I can no longer edit since they show as blank.
Here's an example to illustrate
As can be seen from the shift right click, I can't even select the cells that are there.
I know and have experienced problems such as not being able to scroll at all before, such as this, but this is different as I can scroll down but cannot see the rest of the cells of my tableview. Has anyone else ran into this problem, and would know a solution? It seems like it may have something to do with Xcode 7, as I recently upgraded to it.
Although not ideal, I've found a few work arounds for this problem. One solution is to make a temporary UIViewController with a UITableView, and then drag cells into the temp UIViewController until the cell you want to edit is visible. Once you've changed it, drag all the cells in the temporary view controller back into their correct controller. This is extremely hacky, but so far is the only way I've found to visibly see the cell.
Another thing that can be done is that the cells are still editable in the document outline, meaning constraints and elements can still be modified from there. However, it is difficult, as I wasn't able to see the cells being edited, they still appear to be blank.
Hopefully someone else finds/knows of a solution to this and can post it, I'll leave these two workarounds up though they're far from ideal.

Custom UITableViewCell class in Xcode 4.2

I've been following this Apple Doc to add a custom UITableViewCell that I layed out in an .xib to my project. One problem with the doc is that it seems like it was written for an older version of Xcode.
I'm able to load my UITableViewController that the custom cells are on, but the cells are all blank. My custom cell contains several UILabels, and has a non-default background color. The table that appears when I run has the default white background and no labels. If I change the UITableView's View -> Background on my storyboard, the color of the cells' background changes, but the labels still don't appear.
Of interest is the fact that the data is still in my table's cells. The UITableViewController is itself called as a popover from another controller. When I select one of the cells, the strings from the various label.texts are supposed to be loaded into their own labels on the popover's delegate, and that code works fine (except when I try to include a UINavigationBar in my popover, but that's probably another issue entirely).
I'm still pretty new to iOS developement, so if there's anything I'm leaving out or being unclear about let me know.
Edit - cleaned up code, now is completely different question than when I originally posted, but is still on the same topic. Should I have deleted the old question and posted this as a new question all together, or is it alright that I just edited it?
I'm still not entirely sure what was wrong with what I was doing before, but I managed to get what I wanted. I originally dropped a UITableViewController onto my storyboard set up a popover segue (also on the storyboard) and tried to display the popover with performSegueWithIdentifier. Instead, I now create the popover completely in my code (which I found a nice tutorial for here on SO, by goggling "show popover programmaticly"), without having anything for it on my storyboard. That seems to be the most documented and stable way to show a popover. Once I displayed it that way, my custom cells showed up exactly like I wanted.

Resources