Custom UITableViewCell class in Xcode 4.2 - ios

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.

Related

UITableViewCell's contents disappear when app run in simulator

UITableViewCell shows up in Main.storyboard but doesn't show up in simulator.
I'm using Main.storyboard. In my simple experiment with Swift, I added a TableView, then put a UITableViewCell in it, and then I put an image and a label under the cell's content. It looks okay in Main.storyboard but when I run the project, the content disappear. All I did is purely on Main.storyboard and not touching the .swift file yet.
Here are the links of screenshots of my simple work:
How my app looks in Main.storyboard
How it looks when I run Xcode simulator on iPhone 8, the tableview cell's content disappear
I have searched the problem through the stackoverflow and found a related question here: 'UIImageView doesn't show up in simulator', then I followed the recommended solutions from the forum but still didn't solve the bug.
What I have done so far to solve the bug:
Check if every item in my view has four constraints defining X, Y position, width and height.
Try to check and uncheck the autolayout flag for my Main.storyboard
Make sure my tableview cell's contents (and everything inside my view) has alpha set to 1
Well I haven't check how things looks in my .xib file.
I would like to know if this is a bug, or just a problem in my settings?
I'm quite new to Xcode, swift, and iOS app. Any help or suggestion would be greatly appreciated. If you have the same problem with me, I would like to know your case as well.
The only reason your cell doesn't show up in the simulator is because your tableview is dynamic.
Dynamic table views have data that is loaded at runtime, where there isn't a fixed number of cells, and every cell has the same layout. The Apple tutorial is a good place to start. It guides you through on how to use a tableview/tableviewcontroller.
There is no way around it: You have to code in .swift files if you want to use dynamic table views.
If you are going to use static table views, on the other hand, the number of cells is fixed, and the data is not loaded at runtime. You can use static tableviews if you don't want anything to do with code at the moment.
I had a similar problem. I solved it by deleting constraints for the affected view and starting all over.

Custom TableViewCell contents invisible on iOS9 (Xcode7)

since the upgrade to Xcode 7 & testing my app with iOS9, the contents of some custom cells have become invisible at runtime. There's an emphasis on 'some' here, as this affects only 2 out of 6 table views, all of which reside in different view controllers.
A similar problem was encountered here, but the answer ("check constraints") does not work for me:
Custom TableViewCell contents invisible on ios9 xcode7
The cell that makes trouble is a large placeholder that is displayed when no data is available to be presented in the table.
It only contains a UILabel which is centered by two constraints.
The cell, as well as other custom cells not shown in the picture, are visible at runtime. However, not their contents.
In other view controllers of the same app, the exact same custom cell (same design, same class, same reuse identifier...) work as they should.
However, not in this VC.
Before the upgrade to Xcode 7 and testing on iOS9, the cell's content was visible also in this VC.
I haven't changed anything in IB or the code and double-checked everything a couple times. It's crazy and I am desperately looking for help :-)
Thanks for your time
In the meantime I figured out the answer:
In iOS 8.4, the label is installed in the view hierarchy, whereas it isn't in iOS 9.2 according to XCode's view debugger.
The size class for the label is Regular/Regular, which should suffice for iPad.
When I add the size class Any/Any for the label, it will install correctly.
This is clearly a bug which has been confirmed to my by Apple, but not acted upon yet.

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.

Cell content of a Table View that is part of UISplitView is not being rendered

Here is some background to the issue. I've been looking at it for the past two days and to my knowledge everything is properly configured. To make sure that we are on the same page with versions that are being used I am using the following:
Xcode 6.1
Code is in Swift with some added Objective-C libraries
OS X is 10.9.5
I have UISplitView that was added to the storyboard at a later stage of the project. The project was started form Single View template. Normally the left part consist of a UITableView. When Xcode added it to my storyboard it also had a prototype cell setup. I've added the needed Identifiers and now the prototype cell is accessible in my code. I've implemented and binded the needed delegate and dataSource protocols and checked that their methods are actually being called and working. I've also added background colors to the prototype cell and the prototype label and I see a cell when there should be one but it does not have a label. So here is a list what I've checked:
Data binding is working and data is available. I've also cross checked this with a second UITableView that is in the project and is working properly. This is also true because I see the background color that was set for the cell when I run the app and data is available;
The storyboard does not have any errors or warnings. In fact the project itself does not have any warnings on compilation;
I've reset/removed/recreated constraints multiple times;
I've used the Preview mode and I can see the label rendered properly on my target device and orientation. I've checked this because storyboard sizing can be easily overseen so that you actually don't have the label for this device and orientation but this is not the case;
I've used the new layout debug feature that Apple added in Xcode 6 called view debugger and it does not show a label for this cell. And on the following screen shot you can see that the background of the cell has been properly rendered but there is nothing that is on top of this cell. The cell has been selected for better clarity.
So pretty much I am out of ideas right now. Can you please help me on revealing this mystery?
To answer my own question.
I've created an empty master detail project and saw that this is working there. This made me think that actually there is some kind of a bug in Xcode when you drag and drop an UISplitViewController to your storyboard. For some reason the storyboard is not properly configured. I have no idea what is not properly configured but there is definitely something that is wrong.
Because of the above observations I deleted the UISPlitViewController and used a plain UIViewController to recreate a similar setup that will also work for me. As a result I was able to adjust my already existing code to the new View and use it without logic changes. Which to me just indicates that this is an Xcode issue.
Thanks!

UITableViewController with SearchBar

I have tried both ways below to place SearchBar on UITableView.
TabBarController > UITableViewController(Put SearchBar)
TabBarController > UIViewController > UITableViewController(Put SearchBar)
When I try the second way, then it doesn't work.
(SearchBar cannot show on UITableViewController)
Can anyone tell me what happend?
Here is my xcode project file:
http://www2.zshares.net/tg14vowqzvaw
the usual way to do this would be to put the saerch bar in the header-section of the uitableview its supposed to search. you can do this using the
-tableview: viewForHeaderInSection:
method from the UITableViewDelegate-Protocol. his works in both TableViewControllers and regular ViewControllers that just have a TableView on them. see the mail app on the iphone for an example of this.
if you really NEED the search bar to be outside of the tableview, then you will have to use a regular view controller and just place the search bar in a view above/under the tableView.
other than that, i dont know what to tell you. And what is a TabbedViewController? Do you mean TabBarController? What does that have to do with search bars? Im kinda lacking the time to go through your project, so if you rephrase the question, maybe i can give a better answer?
EDIT-----------------------------------------------------
tableviewcontrollers will do that to you. basically, they will allow ONE tableview to be inside them at a time. also, this tableview WILL ALWAYS fill out the entire space available. Now, there is an exception to this that you cam make use of: Elements like a NavigationBar or a TabBar are allowed alongside the tableview, since they are required for navigation. So if you can put your stuff in one of these, its entirely fine. This my seem counterintuitive, since when do i want just a naked tableview on my screen? the answer is: more often than not. Tableviews are HIGHLY customizable using the UITAbleVIewDelegate-Protocol specified here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UITableViewDelegate
Do yourself a favor and read that doc, i almost guarantee that you will save time in the long run.
For Example: You know the contacts app on your iphone? If you go into the details of one specific contact, you will find a pertty sophisiticated presentation of the data, that will even go into editing mode if you tap edit. It has a header, multiple segments, and a footer.
Surprise: ALL OF THAT is just a single tableview in a tableviewcontroller, customized via the protocol. Let me repeat: you are wasting your own time if you try to do it any other way. tableviewcontrollers exist for a reason. usem them

Resources