UISearchBar appearing at *bottom* of UITableView - ios

Hope someone knows what to do, this is driving me nuts !
I've got a very simple UITableViewController, in an existing application, to which I have added a UISearchBar using interface builder (drag n drop)
Note: This problem exists when testing in either iOS 6 or iOS 7
My problem is that when the application is run, the searchbar is displayed at the BOTTOM of the results
When I click into the search area to perform a search, the searchbar then flicks to the top of the page
At first I thought "this is me", so I deleted the controller completely, including all code, and rebuilt from scratch the page in order to avoid any mistake I may have made. Unfortunately with the same result
The structure in IB is :
The controller code just does bare basic at the minute, just cellForRowAtIndexPath

Just add a prototype cell and put the search bar on top. You don't have to ever use the prototype cell.

Related

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.

UITableView inside of UIScrollView or using TableView Header

I guess this question is more of a best practice question than a problem solving question.
I would like to have a page on my app that has a UITableView at the bottom of it and some buttons/text above the UITableView but instead of just the UITableView scrolling, I would like the whole page to scroll.
I have been searching around and some people say to put the UITableView inside of a UIScrollView and disable scrolling on it and recalculate the height so the table view is as tall as all of it's rows.
Then I have read some other people say just to put the buttons/text in a Table Row Header and just have that scroll with the whole table view.
Which is the better practice and are either of them frowned upon?
Thanks!
Open the main storyboard and on the bottom right hand side you should see a list of view controllers, buttons, gestures etc.. In that list there should be a controller called "page control" that opts for the page-scroll you are looking for as well as the continuous one which you are trying to get rid of, you can just insertt this in to your basic view controller (via drag and drop). As for the button responsible for the segue (turning the page) you can find that in the list too. I can't explain how to program the button to turn the page step by step as I am typing this on my phone at work right now. If you want I can edit this later in more detail

Typing in one UITextField results in not being able to type in any other UITextField with a UIViewController, UIScrollView and AutoLayouts

I have a simple application with a view controller consisting off 3 UITextFields, a DatePicker and a Segment Control.
I have spent a ton of time getting my ViewController scrollable with AutoLayout and a UIScrollView (entirely in Storyboard). The problem I'm getting now though is when I start typing in any one of the UITextFields, I'm suddenly not able to type in any of the other text fields, though I can dismiss the keyboard, select dates in the DatePicker and select segments in the Segment Control.
This was of course not the case before implementing the scroll view and this is only occurring on the actual device rather than in the simulator (emphasising the importance of testing on a device).
I have read through a few SO answers but none of them seem to work.
Please see a screenshot of how my views are set up:
I've also gone onto the UIScrollView and ensured the following three are unticked:
I've enabled and disabled each of them individually but with no luck.
It took a ton of time to get the AutoLayouts working so I honestly hope I won't have to adjust too much here.
My thinking is that because I'm trying to click on a textField, perhaps the View is treating that as I'm wanting to scroll also. Though of course, when I first invoke this view controller, I can click on the 1st, 2nd or 3rd TextField while scrolling, so that makes sense no sense.
One SO question said it was a bug during the iOS 7 beta phases, but my device is running iOS 7.0.4.
My scrollview doesn't have an outlet because this entire procedure was done using Storyboards, but I'm happy to create one if need be.
Reading the Apple docs, it looks like delaysContentTouches is exactly what's required here, but that's turned off in my UIScrollVIew.
Basically any suggestions or assistance with this would be massively appreciated - it's driving me mad!

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

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