Selecting a UITableViewCell in Edit mode - iphone

If I create a UITableViewController - drilling down works as expected. If a user selects a cell and I implement 'didSelectRowAtIndexPath', the cell flashes blue and the next view shows up.
But, if I include an 'edit' button (self.navigationItem.rightBarButtonItem = self.editButtonItem), when the user clicks 'Edit' - the mode correctly changes (all the cells indent and paint an appropriate editingAccessory), ... BUT, the cells are no long 'selectable'.
IE: while in edit mode, when a user selects a cell, nothing is happening. No blue flash. No invocation of 'didSelectRowAtIndexPath', nothing.
When I open the iPhone example 'iPhoneCoreDataRecipes' (as provided in the SDK docs), sure enough, they have a RecipeDetailViewController - that, when put into edit mode, still allows you to drill down. I've downloaded and built their example and it works just fine. I can't seem to find any trickery in their code to enable this 'selectable cell when in edit mode behavior' but I'm just not getting it when I do it.
Thoughts?
Thanks for any time,
-Luther

UITableView has a property allowsSelectionDuringEditing for this.
IMHO it should have been YES by default.

You have to set the allowsSelectionDuringEditing property of UITableView to YES.
The default value is NO.

It can be changed in Storyboard:

Related

IPhone need design idea for tableview

i have a UITableView where i want one cell(database row) needs to be default,
So I am thinking of two options
in TableView upon clicking a cell, change accessoryType to mark just like ringtone selection in settings app
when user enters data, add an option (like radio button or segmented control) to make that cell (database row) as default one
I feel first option is good but we can implement code for that only in didSelectRowAtIndexPath but i need to jump to another view when user click on a cell.
So please give me an idea how to accomplish this
One idea iam thinking is adding an edit button but don't know whether its possible or not.
Thanks
Not sure if i understand your question correctly , but according to what i understand you want a table view in which many values will be there , and you want one value to be default which can be changed later.
According to me these ways would be pretty good,
Changing the accessorytype of the tableViewCell. (Most common way)
Changing the Highlighted property of the cell on loading the tableView.
Adding some image then setting the image as the background view of the selected cell.
Adding custom image view (such as tick or something and adding to the cell).
this code can be put in the viewDidload so your default selected value appears.
Hope this helps.
Don't know what you mean by default. I'm assuming you mean already selected. You might just want to set the accessoryType to the checkbox. That would be Apple's way of doing it.

Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone)

I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have one UITableViewCell that contains a UITextView.
I have also implemented a UIToolbar that appears on top of the UIKeyboard that allows the user to move through the UITextField's by pressing previous or next.
The issue I'm having is two-fold:
I need the UITableView to scroll so that when the next UITextField (or UITextView) becomes the first responder it is visible (even with the keyboard being displayed).
When a UITextField (or UITextView) is selected (without using the previous and next buttons) is should adjust so that the field is visible above the keyboard.
I have looked around at lots of different tutorials however none of them have resolved my issue. Any help you could offer would be hugely appreciated.
ADDITIONAL INFO:
I'm 100% certain that my app used to do all of the above automatically, however I seems to have stopped doing it now and I don't understand why. Is there a reason why this may of happened? Is there some function or something that I may have changed that would destroy this behaviour?
Probably no use to original poster now, but those having an issue like this where it once did work and then stopped...
check you don't have a:
- (void)viewWillAppear:(BOOL)animated
in your UITableViewController subclass!!!
using viewWillAppear in a UITableViewController breaks the "automagic tableView scrolling up when keyboard appears" behaviour.
I only found this by comparing laboriously an old version of a project where it did work with my latest source where it had stopped working.
Check out TaggedLocations sample code from apple. It does the same thing without any extra manipulation.
The key is that your viewcontrollers are following the standard. i.e you are NOT having container viewcontrollers such as UINavigationController within UIViewController.
You have to update tableview Frame yourself programatically...
and i am 100% sure that if you are 100% certain that your app used to do all of the above automatically ...than it is not your app.
Check the docs..here is the link
https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-SW1
You will have to register for keyboard notifications..and then update your tableview frame.
And for next and previous.. you have to programmatically check which textfield became active..and then set the frame accordingly.

iPhone Dev - Implementing checkmarks in a tableview that is in edit mode

I know how to use checkmarks in a tableview when it is not in edit mode. But once in edit mode, it seems that it won't allow me to add checkmarks. Any ideas how to get around this?
Detail accessories are pushed offscreen during editing. This is native behavior and unless you have a peculiar use case it's perfectly fine. If you are editing to sort by checked vs. unchecked, do that automatically. If you really need to, poke around in the methods of your table's delegate. Protocol reference.
Perhaps you can use the built in UIImageView that is on the cell so that when you are editing, if your table allows the editing of multiple rows, when the user taps the cell, the UIImageView is filled with the image of a check mark, but when the table is not in edit mode then the UIImageView is empty.
You can use the allowsMultipleSelectionDuringEditing property of UITableView to decide whether cells are selectable in editing mode.
Then calling indexPathsForSelectedRows will give you the indexPath of the rows the user has selected, and then perhaps you can have some logic to edit the cell's UIImageView property.
A bit hackey, but I hope this helps!

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];

why does my UITableView not appear to start in editing = YES mode when initialized?

I have a UITableViewController subclass. I set self.editing = YES at the end of the viewDidLoad method, but when the table is displayed the little red 'delete' icon does not appear next to each row.
Then, I added an edit button to the navigation item:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
When I launch the application now, it starts in edit mode (I can tell because the edit button says 'done') but, again, the delete icons don't appear. Then if I toggle it with the edit button twice (once to turn it off, then once to turn it on), the red delete icons appear.
So, my question is: why aren't the table cells displaying correctly when first displayed? I've tried moving the self.editing = YES line to other places in the code, like in the init function or the viewWillAppear function, but no dice. It seems like this is a result of funny ordering somewhere (e.g. table cells initialized before editing is set, or something), but I can't figure it out; running the debugger shows that the viewDidLoad call happens before cellForRowAtIndexPath, as one would expect.
Other notes:
Yes, I am having editingStyleForRowAtIndexPath return UITableViewCellEditingStyleDelete. But from debugging I've verified that that function is not even called after the first load. (It gets called after I toggle editing mode twice.)
d'oh, adding it in viewDidAppear (or, better: viewWillAppear) did the trick. Thanks #lukya and #willcodejavaforfood for suggestions.
I feel silly. I swear I thought I'd checked that.
Moral of the story: setting the editing property too early makes page elements not display in editing mode. (Doesn't that seem like a bug?)
Try using the
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
method in UITableView