uitableview's index is shrinking - iphone

I have an app very similar to address book of iphone. The entire search and index stuff is implemented using the searchdisplay controller. The problem is, from the search results when i click some cell, it actually loads a new screen and while pressing back and going to home tableview screen the index is shrinks
The possible reason which I could think is the keyboard. Is there way to make auto resizing of the index on the right side of the uitableview even after the keyboard appears for searchbar.

Do you mean resize the index to the full length of the table after you have removed the keyboard for the search has gone? If so, use can reloadSectionIndexTitles.

i got the problem in my source code. I actually release the keyboard when i am loading the view from the search results. when i come back from the newly loaded view and press the standard cancel button it loaded the tableview with half index view. Now i deleted the code which actually releases the keyboard. Then it worked normally.

Related

Select the first element in view for Voice Over

I am using Xcode to make an iOS app. When I segue into the next view controller, it has objects in the following order from top to bottom on the screen: label, collection view, button. When I use voiceover, I want the first item on the screen to be in focus (the label). However, whatever I do, it is always a particular cell from the collection view that is selected by default (somewhere in the middle of the screen). In landscape it is a different cell and in portrait a different cell. But every time it is that same cell. I tried using UIAccessibilityPostNotification, as well as using delays and other things. Nothing seems to work.
Should be posted when a new view appears that encompasses a major portion of the screen.
Optionally, pass the element that VoiceOver should move to after processing the notification.
UIKIT_EXTERN UIAccessibilityNotifications
UIAccessibilityScreenChangedNotification;
You need to provide
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, youLabel);

Can't get UITableView list to scroll in iPhone simulator

Is there a simple explanation for why a table will not scroll in the iPhone simulator? I have a tab bar application that I built with the standard template. I created a UITableView in the second tab controller. I initialized the objects with a list of items and they display nicely. However, neither the up/down arrow buttons work nor does the scroll. The rows can be highlighted.
Thank you.
You should try to hold by clicking on table cell row and drag it up or down to move it
I am not able to understand the actual problem but follow the below link to know more about
Tabbarcontroller and TableView :
http://iphonebyradix.blogspot.com/2010/12/uitabbarcontroller-overview.html
http://iphonebyradix.blogspot.com/2010/10/uitableview.html
I think you should click on a cell, hold the mouse, and drag the mouse up or down. That action acts like a finger tap.
Strange new one for me on a new forcetouch Macbook Pro...
Hardware -> Touch Pressure -> Use Trackpad Force I turned that off because my scrolling was being interrupted by Force Touches.... I had no idea what was going on.
Use 2 fingers to drag and then scroll, it should work.

Looking for a better way to hide search bar at top of view

I have several views where I want the search bar to be hidden unless the user scrolls it down to use it. I use this command to achieve this:
[self.tableView setContentOffset:CGPointMake(0, 44) animated:NO];
This works ok, but it's not ideal; any time something happens that causes the table view to reload, it has to be repositioned again.
Now I have a view where I want to completely hide the search bar from the user, meaning they can't even scroll down to get to it, but I want to keep the scope bars at the top of the table. So basically I want to scroll the search bar off the top of the view and keep it there, while leaving the scope bar portion of the control visible. setContentOffset isn't doing it for me anymore, since the user can easily undo it.
Is there an approach to this that I'm overlooking?
Thanks in advance!
Update: I never figured this out, so ultimately I changed my design.
Although it's probably a bit late, when you say "any time something happens that causes the table view to reload, it has to be repositioned again", are you saying that every time your UITableView reloads it scrolls to its top? This isn't the standard behaviour of a UITableView.
In regards to the second part of your question regarding your UISearchBar's scope, I'd strongly recommend replacing the UISearchBar with your own UISegmentedControl (that's all the scope of a UISearchBar is anyway), so that the user isn't confused by there being an off-screen UISearchBar that doesn't do anything.

Reloading / Displaying searchResultsTableView of UISearchDisplayController after search method iteration is finished

I have modified the code of Apple's sample iOS project TableSearch in order to use it for searching a webservice by parsing its contents. Everything I have implemented works fine except for one ugly detail when performing a search using the SearchDisplayController's SearchBar. I have changed the behaviour of the SearchDisplayController to make it call my search function first when the "Search" button was tapped.
The problem is that when the search iteration (which is performed in the background in an NSOperationQueue) is finished the "searchResultsTableView" (of the searchDisplayController) is not automatically displayed or not assigned the resulting content. If you then change the SearchBar's text or tap the "Cancel" button from the view which appears when you touch the search field (see TableSearch) the correct TableView appears with the search results. I simply want to have this step to be executed right after the search operation is finished, so before you interact. At this stage the "No Results" label is currently displayed. The methods "filterContentForSearchText" and "shouldReloadTableForSearchString" are unchanged from the original TableSearch project.
I have taken a look at different class references of the SearchDisplayController and its attributes but I could not find any final solution yet.
I have tried the following in a section which is definitely iterated after the NSOperation is finished but it does not seem to solve the problem.
[self.searchDisplayController.searchResultsTableView removeFromSuperview];
and
self.searchDisplayController.searchResultsTableView.hidden = YES;
These operations both have the correct view I want displayed BUT scrolling is disabled until you change the state so that the view is hidden again. It is possible to select TableView cells, though. I basically want to have this just with scrolling enabled...
Thanks in advance for your effort!
I have same problem and I just solved it. I had exactly same problem, I wanted disable instant search and when I hit search button, the table didn't load but when I clicked cancel, it loaded up. And If I scroll on table view that didn't load correct result after search, it crashed due to index out of bound.
The thing you need to do is reload searchResultTableView not current tableview. After you filter out your data by search term, put
[self.searchDisplayController.searchResultsTableView reloadData]
to reload your search result, and it will shows up after you hit search button.
Hope this help
I found that setting the searchBar.text causes searchDisplayController.searchResultsTableView be added to self.view, I solve it like this:
self.searchBar.text = #"xxxx";
[self.searchDisplayController.searchResultsTableView removeFromSuperview];

UITableView Won't Scroll In Certain Conditions

My app has a set of categories. A category can have sub-categories.
DirectoryCategoryController is the first screen, displaying all the top-level categories. Works great. When you tap a cell, if the category selected has sub-categories, I instantiate a new instance of DirectoryCategoryController and push it to display the sub-categories. From there, you tap a sub-category and see the contents.
The problem is that while the top level works fine, when I tap in and see the sub-categories, the table view won't scroll. The search bar takes touches, the table cells take touches but up and down scrolling does not work, like the table view is vertically frozen in space.
If I tap the search bar and hit cancel or if I go into a sub-categories contents and then hit back, the very same table view that didn't scroll works just fine.
Also, if the table view has more items than fit on the screen (about anything bigger than 8 in this layout), everything works.
Very odd problem ; kinda blowing my mind. Any insight?
So, I figured this out and thought I would answer as a reference.
At this point, I think it may be an iPhone OS bug and I'm filing a RADAR.
A UIScrollView, of which UITableView is a subclass, will not attempt to scroll if everything fits on one screen.
In my case, it appears the scroll view thought everything fit (it was very close) but it didn't. Actually, if you removed the UISearchBar from the UITableView, everything would have fit and it wouldn't need to scroll. My guess is that it's incorrectly determining the geometry when the UISearchBar is attached.
Anyway, the work-around was to add this:
[self.tableView setAlwaysBounceVertical:YES];
The odd thing was that when another view was pushed and then popped, the vertical bounce worked fine, furthering my suspicions it's an iPhone bug.
I noticed the same thing when using A UITableView with a UISearchBar as the header view, as configured in Interface Builder in Xcode 4.3.1. In my viewDidLoadMethod, I added the following code and it fixed the problem for me:
self.contactsTable.bounces = YES;
I believe that it's a bug that disables the bounces property, but it can be fixed by re-enabling it.