Error in UITableView Section Header - ios

I have an ios app written in swift. I am trying to make an input form using Eureka. So first I copied its example code into my FormViewController. The code is exactly same of RowsExampleViewController in the example code. The resultant output is following:
The expected output (as shown on github page of Eureka) was:
As you can see that the Section Headers are floating for some reason and not properly formatted.
Whats is the possible problem I should look at? Please let me know which section of code should I paste. The ViewController code is exactly same as that of example.
Also, I faced similar problem while using SwiftForms. I think there might be some connection.

I just had this happen when I used a UITableViewController in the storyboard and set its class to be my subclass of FormViewController. I ended up removing it and using a UIViewController instead, placing a table view as a subview of the VC's view.
I think the problem is, if you use a UITableViewController it has some of its own assumptions and settings, and the FormViewController is creating its own, so you end up with two section headers at the same time.

Related

Swift-How to add a parallax header like the one in Spotify?

I was wondering if anyone knew what the best way of creating a similar tableview header effect to the one in Spotify was. I have looked at libraries such as CSSStickyHeaderFlowLayout, but they are written in Obj-C and are for CollectionViews. What's basically got to happen is that as the user scrolls to find more tableview cells at the bottom, the header stays in the same place and the top cells start covering it. This is seen in the example section of the git page of the library above.
Thanks in advance for any help!
Try using the solution found here
The original example uses Obj-C but the asker's response uses Swift. They also make use of TableViews rather than CollectionViews

reloadData() and setting IBOutlets without Interface Builder

I have created a UITableView inside my UIViewController programmatically using this guide on the Speak Objectively Blog.
However I now have the problem that .reloadData() isn't refreshing the view. However if I drag or move inside the UITableView the data appears correctly.
This answer suggests that I haven't set up the outlet. To my understanding IBOutlets are for connecting elements in the Interface Builder to the code. Please correct me if my understanding here is wrong.
How do I set an outlet if I created the UITableView programmatically?
The guide creates a UITableViewController. It has already an instance of UITableView on it, and it is the one you see in screen. There's no need of creating outlets, so that answer is not actually the answer to your problem (but might be somehow related)
What I can imagine is that you are sending the message somewhere else.
As you can see in the Table View Controller Class Reference , you can get your table view by self.tableView (or just tableView in swift)
So make sure you are sending the message to self.tableView.reloadData()
If it doesn't work, sending part of your code will help us to see better than to imagine where could be the problem ;)
If self.tableView.reloadData() doesn't work on its own, use:
dispatch_async(dispatch_get_main_queue(), {self.tableView.reloadData()})
or
dispatch_async(dispatch_get_main_queue()) {self.tableView.reloadData()}

Strange entanglement between two UITableViews in XCode5

SUMMARY BEFORE EXPLANATION
It’s as if the storyboard is treating the Tables as pointers to a single instance, simply because I copied and pasted through the storyboard. I am recording this here in part as a reminder to myself (I am an avid user of Stack Overflow) and as a warning to others. And of course, I want to know if there is a simple way of truly disentangling the two without having to recreate one of the ViewControllers from scratch. please, read on for explanation.
BACK STORY
First I created CatUIViewController using the storyboard. I completed the whole thing along with .h and .m files. Then, needing a similar ViewController for Dogs, I dragged and dropped an empty ViewController onto the storyboard from Object Library, and then I copied and pasted the entire UITableView from CatUIViewController to DogUIViewController. Then of course I did the same with the .h and .m files. Really the only difference between CatUIViewController and DogUIViewController is that Cat has two buttons in it’s header while dog has an UIImageView, along with other data that both headers share.
Naturally, Xcode does all the connections for me the moment I pasted into the Dog equivalents. It wired all the IBOutlets and IBActions automatically: a nice feature of Xcode.
FURTHER DETAIL
Both table views have a background image. And navigation from Cat to Dog is possible because my app is using UITabBar — no other linking exists between the two. Furthermore, while Cat leads its Tab, Dog is way down the line in its Tab’s NavigationController.
THE PROBLEM
The problem is this: If I am in DogUIViewController and click the tab to transition to CatUIViewController, after the transition the background of DogUIViewController shows up as the background of CatUIViewController. In fact, if I visit DogUIViewController and then navigate to any other page so ever… the second I click on the Tab for CatUIViewController, mysteriously it first shows the data for DogUIViewController before switching to the correct data about 1 second later. Another strangeness is that the converse is equally true.
I have been investigating the code to see what might be the cause and so far I have found nothing. It’s as if the entanglement is happening at a layer in Xcode that is not exposed to me: I review the Connections Inspector, the .h and .m files and I cannot find anything so far. I am hoping it is a simple oversight on my part so I keep digging. But just in case it is not and someone else has resolved something similar, I am here asking.
Whereas you copied and pasted not only the UITableView but also both the .h and the .m file, the possibility for errors abounds. But of particular interest to me is that you mention differences to exist exclusively in the header files. This to me means the likely cause of errors is your data source. Wherever you are fetching the data, it takes a split second so that the new data is delayed just enough for the old data to show up. So I am ending my response with a question: How are you fetching your data? Are you caching the data? Are you cleaning property? For example, if you are using notification for the server to update your view controllers, viewDidUnload is deprecated so I wouldn't use that to unregister notificatoins. In whatever the case, you at your data source.

IOS Why can't I drag connections from Storyboard elements to their respective ViewController?

I'm revising my app so that the first scene is a Standard ViewController containing a UITableView and a UIButton. This replaces the original UITableViewController.
Problem is, I can't (Control or Right-Click) drag from these elements to set outlets or actions in the associated ViewController class file.
I've checked and rechecked to be sure the identity of the VC is correctly set to the appropriate VC custom class file, but still no success.
I wonder if it may have to do with the fact that I deleted (trashed) the original UITableViewController and class files, although the .h file continued to show up in the Custom Class list under the Identity section for a while. It appears to be gone now.
I've cleaned and rebuilt several times, and quit and restarted Xcode, but without success.
Can anyone lend a hand?
Thanks!
Edit: Pursuant to a response to a similar question on SO, I checked the name of the ViewController class file by looking at the Storyboard as Source Code. The ViewController is in fact named correctly.

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