iOS UI - how to tell user that there are no data in table view? - iphone

This is the situation:
A user filters a database by selecting keywords from a list, then presses "search". This pushes an instance of a UITableViewController subclass onto the navigation stack.
In the viewWillAppear: method, data are fetched from Core Data and stored in an ivar, ready for the table view's data source and delegate methods.
So far so good.
The UI problem arises when there are no results.
This simple architecture means that an empty result set yields an empty table view with no explanations.
It would be good for the UI to tell the user something like "Your search gave no results, please try with fewer keywords".
My question is this:
What is the best way to provide relevant feedback to the user, without having to change the architecture too much?
I was thinking about using the table header, but what do my esteemed colleagues here think?

Using the table header is not a bad option. You can go for that. You can also try other options like showing the info in a simple label or perhaps even an alert. But personally I wouldnt recommend the alert.

U can show that in UIAlertView.

You could add / show a UILabel to your view that says "No search results" (or something like that) when the table does not contain any data.

After fetching the result from core data... just count the number of rows in the result and then before displaying Table View just check if Count>0 then only go for table view ... else just display UIAlertView... this will save u from unnecessary display of UITableView

You can put AlertView when your ivar is empty and in alert button index return to the main view from where you are entering your search. This is the best way for you without changing your architecture.

Related

How to add a search bar to pick sorted data from Picker view

Hi guys i have added a picker view to pick areas from it.This picker view contains more than 200 areas so it is difficult to scroll and select from picker view.
Is there any way to add a search bar and connect it with picker view?
I tried doing this by using search bar delegate method by overriding it but i am not able to achieve the goal.
So please help me so that i can do it or if any another way possible then also tell me.
Picker view is for small number of selection. Use table view instead for such big number of options.
Just to back up my statement, the Apple Human Interface Guideline says
Consider using a table view, instead of a picker, if you need to display a very large number of values. This is because the greater height of a table view makes scrolling faster."
I agree with barley that the PickerView is an awful vehicle for large selections; if at all possible to use something else, that would be appropriate and best, but having said that:
The YHCPickerView looks promising from:
http://code4app.net/ios/PickerView-with-Search-Bar/509fb2e86803faf25c000000
From a cursory view of that class, it appears that it has several different and distinct UI elements, the text field for collecting search criteria, the button for enacting the search, and the basic picker view. The search criteria simply and directly filters the picker data/model when the button pressed event occurs. That way you are simply editing the actual data from the picker.
If you handle each of these separately it should make it simpler to create what you want, since you only have to handle the basic functions and delegates of each individual UI element and linking together their effects rather than trying to hijack an existing delegate.
-Cheers

UITableView display search results in separate tableview

I am implementing real-time searching of a UITableView. I would like to display the results in a separate table view (in it's own UITableViewController class). Is there a way to simply replace one tableview with another once the user begins typing in the search bar?
Refer to UISearchDisplayController. It will surely provide what you require :)
Create two tableViews, tableList and tableSearchResults. Also declare one more tableView namely, tableCurrent. Initially make tableCurrent to point to tableList, then load the objects into tableCurrent. You can use this (tableCurrent) to display contents and handle selection events.When user fishes searching, assign tableCurrent to tableSearchResults, and then load objects from search results array. This will make two table views, one for Listing and other for search reasults...
Happy programming
There is little reason to use two actual tableViews, if only one is visible at a time. You could just change the .dataSource and .delegate properties. (If they are sized and styled the same anyway.)

Handling an empty Table view

What I am trying to do is pretty simple, I just want to display some message to the user that there are no entries in this table, rather than just displaying a blank page. An ideal example is in the app store, if you search for something, but get no results, it just displays in the middle of the page "No Matches".
I've looked at a few solutions, and decided that the one i like best is here But theres a few little problems with it:
1) I can still drag around the image as if it was just a very large cell in the tableview
2) when I try to re-add the tableview to the tabelviewcontroller's view, I seem to get some kind of infinite recursion that eventually crashes
Anyone know a simpler way to do this? Or how I can resolve my current issues?
Don't remove the tableView, just add an UIView with your message (i.e. UIImageView) on top off it. It only needs to be big enough to cover the tableView. Place something like
at the appropriate place in your UITableViewController:
if (results == 0) {
[self.view addSubview:noResultsView];
}
Dan F it's very easy all you need to do is the following:
if there is no data in your source, add one object like No Data Found
Set a flag like BOOL bNoDataFound = YES
in CellForRowAtIndexPath delegate check your flag is YES fill the only cell with your text that you set before

UITextFields losing values after UINavigationController activity

This is going to be hard to demonstrate in code, but maybe you can picture it with me.
I have a view that contains two UITextFields, "title" and "descr". That same view contains two UIButtons that push another controller onto the navController to get more detail from the user about the object we're assembling and ultimately uploading to my server.
It appears that pushing another view on, doing something, and popping it back off results in the two UITextFields keeping their content VISUALLY, but the .text property of those fields becomes NULL. I've confirmed that if I do my two push-pop fields before filling in those UITextFields, I get my data when I upload, and if I do them in the opposite order, I don't. It LOOKS like there's data there, but I get nothing when I NSLog their .text properties.
Is this normal? Do I need to just design around this? Or is this as weird as it seems, and I should be looking deeper at causes of this?
I bet that you loose the references to the text fields.
Try to check 2 things:
Check if you have anything except the text (e.g. color, font, text alignment) - maybe the text view are nil
Try to write something into the text fields after the push-pop and then see if you have the .text property
Took me a while to get back to that (my BIG stack of bugs is getting ever smaller as release date approaches!), but I figured it out. On viewWillAppear, I was doing a reloadData on the table that these fields were in, and that was resetting my form fields. I stashed my data before that reloadData call and re-populated them in the tableView:cellForRowAtIndexPath: method, and we're golden.

How to implement "Load 25 More" in UITableViewController

I am working on an iphone application. Application loads plenty of records from a webservice into table view controller. I would like to load 25 records initially and remaining in 25 batch on clicking something like "Load 25 more" at the end of the table view.
Any help would be grealy appreciated.
Thanks
Just put a button connected to an Event in your table footer. When the button is clicked, append the next 25 results to your already existing array of items.
After that, just do a [self.tableView setNeedsDisplay]. I use that to let my table know I have extra data in the table. By using that, there is no need to scroll to the right line in the table, because it keeps its original position.
Also, why call the viewDidAppear method, this seems wrong to me, because (ofcourse) the view already appeared and all declerations and assignments you do there are re-done. Just put the stuff you need to be done while viewing the view AND when you are appending data in a seperate method and put call that method from your button-press event and from the viewDidAppear event.
I wrote an example project that does this which you can download from GitHub https://github.com/Abizern/PartialTable
I do almost the same in my application, getting 50 first records from webservice. As a table footer I have a view with next/previous buttons, that when pressed launch a fetching request for next/previous 50 results. After fetch request is processed I call viewWillAppear:animated: for my view controller and inside to [self.tableView reloadData], so these results show up in the same table view. Of cause I'm keeping the data each time only for presented results, but it depends on your needs.
Hope this helps
I wrote something that does exactly what you describe, an put it on github : https://github.com/nmondollot/NMPaginator
It encapsulates pagination, and works with pretty much any webservice using page and per_page parameters. It also features a UITableView with automatic fetching of next results as you scroll down.
Hope it'll be useful.