How do I change the UITableView drag controls and behavior? - iphone

I am trying to use the the dragging functionality that UITableView offers while in editing mode to rearrange some custom views in the cell.contentView. I am successfully getting editing mode turned on after a long press on the cell and turned off following a reorder.
Here is a picture of how I have things set up: http://cl.ly/image/081k3G0A3f2I
The problems I have are:
The contentView indents no matter what I set ShouldIndentWhileEditing to.
I would like to get rid of the delete control and the drag control.
The whole contentView should be the drag area instead of just the little drag control area.
Help with this would be appreciate. Thanks.

Yes, you can customize the look of the drag controls. Try overriding layoutSubviews. In that method, check for editing status and draw /position your elements accordingly.

You can't get rid of the drag control if you have enable row reordering. The API does not allow any customization of row reordering. The only solution would be your own custom table type view.
You can get rid of the delete control. Simply return UITableViewCellEditingStyleNone from the tableView:editingStyleForRowAtIndexPath: delegate method.

Related

How to change the UISearchBar from round to rectangular? [duplicate]

I'd like to change the appearance of the default UISearchBar. As an example, how would you recreate the search box in the Google iPhone app as seen below? How would you overlay an image to produce this effect?
(source: isedb.com)
Upon some investigating of possibilites to customize the search bar, I'm inclined to say this is a custom component that has nothing to do with UISearchBar, but instead recreates its functionality.
You don't need to subclass anything.
Create a new UIView that has the buttons and text field and then when then entire view is going to load do this:
[self.searchDisplayController.searchBar addSubview:customSearchBarView];
Make sure to set the new text field as the first responder so it has access to the keyboard.

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!

How to move editingAccessoryView of custom UITableViewCell in edit mode?

I have custom TableViewCell and want to use it in edit mode only. I like the delete accessory view in left side and reorder-control view in right side. But I want to move it a bit to the center of the cell. Can I do it?
I try something like this [cell.editingAccessoryView setFrame:()] but without any success.
Or the only option here is fully custom cell?
The reason why the view's frame isn't reset is likely because self.editingAccessoryView is nil, which is the case unless you set it with a view of your own.
Yes, you should try providing a custom editing view of your own and reset its frame property, but this may interfer with other existing views.
So your best bet is surely to make a full custom cell.

UITextView in UITableViewCell scrolling problems

Ok. I have made a custom cell for my table, and it contains a text view. When I have multiple lines in the text view, I can scroll up and down, but in doing this the table also scrolls. How can I stop this behaviour? If anyone needs parts of my code or further details, please just ask. I am more than willing.
Thank you for your help
I suggest you to move text edit (write) behavior to another view controller. If you need read-only functionality from it then just increase cell and textView height.
Did you try setting canCancelContentTouches to NO? It's a property of UIScrollView, from which UITableView inherits.
Your custom cell seems to pass on touch events to its container class as well as utilizing them itself. Did you implement any - touchesBegan:, - touchesMoved: or - touchesEnded:?
If you make use of a touch events, you should not pass them on in the responder chain.
When the text view has focus, set scrollEnabled=NO on the table view. You may have to manually remove focus from the text view and restore scrolling when a touch occurs outside the text view.

UISearchBar: Changing the appearance - Shape, Background, Overlay an Image

I'd like to change the appearance of the default UISearchBar. As an example, how would you recreate the search box in the Google iPhone app as seen below? How would you overlay an image to produce this effect?
(source: isedb.com)
Upon some investigating of possibilites to customize the search bar, I'm inclined to say this is a custom component that has nothing to do with UISearchBar, but instead recreates its functionality.
You don't need to subclass anything.
Create a new UIView that has the buttons and text field and then when then entire view is going to load do this:
[self.searchDisplayController.searchBar addSubview:customSearchBarView];
Make sure to set the new text field as the first responder so it has access to the keyboard.