How to move editingAccessoryView of custom UITableViewCell in edit mode? - iphone

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.

Related

How do I change the UITableView drag controls and behavior?

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.

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.

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!

Updatable, custom view on a UIToolbar

I want to make a small area to present some information in the middle of a UIToolbar and was wondering what the best way to do this is.
I need to show some text and a graphic, both of which need to be updated (around every 3 seconds) as new information arrives. The graphic is similar to the iPhone signal strength indicator, so it can be either custom drawn or selected from one of 3 graphics (low, medium, high strength).
I'll probably use initWithCustomView: to create a UIBarButtonItem, although I would like the view to be clickable (to allow the user to change the information shown).
What's the best way to make that view? Can I use a NIB, or do I need to do custom drawing in the view? What's the best way to update the buttons? I'm assuming that I'll have to remake the toolbarItems array each time and set it when the information changes. Is there a cleaner way to do this? Thanks.
Using initWithCustomView: sounds like a good way to go. You can create your custom view any way you want: with a NIB, by drawing it, even using images. It can also have its own subviews. It can be any object that inherits from UIView. (So, if you wanted, you could even make it actionable by using a UIButton, a custom UIControl, or a custom UIView with a gesture recognizer attached.)
You shouldn't have to remake toolbarItems (or, for that matter, do anything with it after you've added all your button items) if you just keep a pointer to your custom view UIBarButtonItem. It could be an instance variable. Then, to update the custom view, you could access it as you would any other view. I've never actually tried this, but I can't see any problem with doing it.
You sound like you had it mostly figured out. Hope this is helpful.
I needed the same solution and was hoping for some code examples from you. So I ended up doing it all in IB and the steps are here as follows:
Create UItoolbar in IB with no Items. (A Bar Button Item will be added again once you add the UIView)
Add UIView as subview of UIToolbar
Add UILabels to subview of UIView that is already a subview of the UIToolbar.
Create IBOutlets from UIToolbar, UIView and each UILabel and then you can reference the labels in your app.
I did set the backgrounds to clearColor so the text appears on top of UIToolbar without any box or borders.
And the text updates dynamically which was the desired outcome.
Hope this helps someone as this has been eluding me for a while.

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.