Reloading the search table view controller - iphone

I have a table view with a search bar. When I put some text in the search bar & search data I display different rows under different sections. I have enabled UIGestureRecognizer on the section header to collapse the rows. Once user tap on the section header I set the data objects to nil leading to number of rows returned for those sections as 0.
After the I call the following piece of code to refresh my search table view. It all works fine with exception that I can see "No Results" on the screen just below my collapsed sections. This works fine in non-search mode - collapsing the sections does not display "No Results" message there.
[self.searchController.searchResultsTableView reloadData];
I could see a private property _noResultsLabel & a _searchDisplayControllerFlags option as noResultsMessageAutoDisplay (set to 1) inside class UISearchDisplayController. Not able to reset them.
Any idea on this?

Related

Display/Hide cell in table using Birt report

I Have two cell in one row.
I want to show and hide based on condition.
For cell visiblity expression option not showing this is showing only for text/label.
In the script I am adding
if(params["chk"].value == "both"){
this.getStyle().display = "none";}
Any solution please?
You cannot hide a cell. This wouldn't make sense. You can hide the content inside a cell, or you can hide whole rows or columns.

Search results does not match all tableview data

I'm using tableview with custom cell contains label and sender(button) , I have data on that tableview and when I make a search i got match results on the label only the sender(button) always match the first field on that table view before the search operation,and when i press that button the button toke an action with the first object in tableview before the search operation not the searched item.What I'm asking is how to make the search results match the custom cell content in label and the sender status in the same time ,I'm using swift 2.0 x code 7.1 ...
Thanks

UITableViewController- showing only rows with content and an image where there is none

When creating a UITableViewController there are two situations that create an "ugly" UX
calling/open it without any data in it --> shows an empty table (i.e. empty rows,UITableViewCell, as many as fit in the window)
calling/open it with fewer rows of content that fit the window --> show the full rows followed by empty rows
I wish to receive the following result:
if there is no data show a picture or view with text - there isn't any data yet or something like that
show only the full lines and no more rows (blank or background image)
Is there a way to achieve that?
To add these effects, you will probably have to make your own UITableViewController from a regular UIViewController, and even subclass UITableView. If you have a regular UIViewController with your filler image/text as the background, you can place a UITableView on top and hook up the delegate/datasource. Now, in your code, detect when there is no data available and set the hidden property of the UITableView accordingly.
As for the following empty rows, you will either have to turn off the row separators (in IB), or subclass a UITableView (can't help you there). Good luck!

iPhone: Cells order changes in UITableView Section After Call to reloadSections: Method

I have a table with two sections. A segmented control in first sections changes which rows are displayed in the second section. My problem is that the order of the rows and which row are displayed in the second section shifts improperly upon each subsequent press of a button in the segmented control.
I allow a user to add a product to a shopping list 3 different ways: by name, by barcord and by taking a picture with a camera. I have 3 buttons in a UISegmentedControl so the users can select which method to use. Depending on which segement the user selects the fields in the second segment should change to show cells relevant to that method.
Section 0:
0 row with segmented control showing name, barcode and camera buttons
Section 1:
// button zero, name button
0 row with textfield
1 row with textfield
or
// button 1, barcode button
0 row with textfield
or
// button 2, camera button
// shows camera view
I've put placeholders in each UITextField.
Each time a button in the segmented control is clicked, I call a pickOne: method that updates the tablevew. In that method, I construct a NSIndexSet with NSRange of (1, 1), and then I call the reloadSections: method of the UITableViewController with the NSIndexSet as a parameter.
When the view appears for the first time, everything is ok but when I click the buttons repeatedly, the order of the cells changes. Cells containing the two textFields for the button0 and the new placeHolders are written over the old ones.
Worse, sometimes when I click on button 0, it shows me only the second cell of the two cells.
My detailed code can be seen here http://pastebin.com/9GwMpCS9
I'm seeing a couple of problems.
The first big one is that you're adding subviews into the cells bypassing the contentView. Subviews in predefined styles are broken up into different parts depending on their roles. You have the editing control, the content view, and the accessory view. While you can add directly to the cell's view, there'll be odd behavior because the predefined cells are expecting the content to be in the content view.
I think what's causing your problem is that you're adding subviews every time a cell is decorated but you never remove them. When a cell is dequeued there's no guarantee that everything is restored to the pristine new condition as if it was alloc'ed. Things like custom accessory views that aren't removed can be left behind. I'm pretty sure that's happening. You're collecting visual trash on cells that should be clean.
I believe your problem is here.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//....
if(addMode == NAME) {
if(indexPath.row == 0) {
[cell addSubview:nameTextField];
}
else if(indexPath.row == 1) {
[cell addSubview:categoryTextField];
}
}
else if(addMode == BARCODE) {
[cell addSubview:barcodeTextField];
}
else if(addMode == SCAN){
//Scanning mode
}
}
return cell;
}
This because the table always shows has having two sections, this method is always called for section 1. Regardless of the input type selected, it creates or dequeue a cell and returns it. Whenever addMode==SCAN, it randomly dequeues one of the previously used cells for the name or barcode addMode and returns that.
I suggest that you remove the SCAN logic from the table altogether or that you create a row for the camera.
I think the latter the best UI. With the first two buttons, the users is presented with a choice in the second section. You should maintain that pattern with the camera choice. Just have a cell that displays a button that evokes the camera. Yes, it adds a second step but establishes a kinetic pattern for the user: Select input type in section one then select an appropriate cell in section two. The user shouldn't have to stop and think each time whether they need to hit one of the rows in section two or not. They should just do so automatically.

UItableview returns more row?

i have done like
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
tableview is in UITableViewStylePlain.but it shows correctly 3 data on 3 tableview cell.but after that there is empty tableview cells ...but when i declared UITableViewStyleGrouped, it shows only 3 tableview cells... perfectly...what i have to do disappear empty tableview cell
in UITableViewStylePlain..any help pls?
Your table contains 3 table cells and those cells beneath it are not empty table cells. The row seperators are just drawn based on the previous row height giving the impression that there are more cells than you actually specified.
You could set the separatorStyle of the table view to UITableViewCellSeparatorStyleNone, either in code or in Interface Builder. But doing so disables the seperators all together, so you would have to draw some kind of separator yourself in your cells if you still wanted a grafical separation between the actual cells.
Another option would be to set the color of the separator to the color of the background of the table.
I myself would not worry about this if you're application has a standard table look, as it's default behaviour & users should be used to seeing that. Altough I must admit that I have set the separatorStyle to none in a previous project, because the table had a look that deviated from the standard table look. I did have to draw a fine separator line at the bottom in the table cell.