IPhone UITableView - Delete Button?

Iwat's code doesn't work for me. But this works (void)willTransitionToState:(UITableViewCellStateMask)state { super willTransitionToState:state; if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) { for (UIView *subview in self. Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { subview.

Alpha = 0.0; } } } } - (void)didTransitionToState:(UITableViewCellStateMask)state { super didTransitionToState:state; if ( state == UITableViewCellStateShowingDeleteConfirmationMask || state == UITableViewCellStateDefaultMask ) { for (UIView *subview in self. Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { UIView *deleteButtonView = (UIView *)subview. Subviews objectAtIndex:0; CGRect f = deleteButtonView.

Frame; f.origin. X -= 20; deleteButtonView. Frame = f subview.

UIView beginAnimations:@"anim" context:nil; subview. Alpha = 1.0; UIView commitAnimations; } } } }.

Iwat's code doesn't work for me. But this works. - (void)willTransitionToState:(UITableViewCellStateMask)state { super willTransitionToState:state; if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) { for (UIView *subview in self.

Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { subview. Alpha = 0.0; } } } } - (void)didTransitionToState:(UITableViewCellStateMask)state { super didTransitionToState:state; if (state == UITableViewCellStateShowingDeleteConfirmationMask || state == UITableViewCellStateDefaultMask) { for (UIView *subview in self. Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { UIView *deleteButtonView = (UIView *)subview.

Subviews objectAtIndex:0; CGRect f = deleteButtonView. Frame; f.origin. X -= 20; deleteButtonView.

Frame = f; subview. UIView beginAnimations:@"anim" context:nil; subview. Alpha = 1.0; UIView commitAnimations; } } } }.

Thanks for your reply, one question (I havent tested the code as yet) but what is the line subview. ** – Mick Walker Feb 5 '10 at 23:42 Sorry. I'm new to stackoverflow.

I just wanna make this piece of codes bold. When I clicked the bold button, ** was added to the end. – nonamelive Feb 6 '10 at 8:09 I finally make it work, and it works pretty well!

– nonamelive Feb 17 '10 at 22:14 2 Might I add that this is relying on private class names. Even though the private symbols are being hidden from the compiler and linker, they're still being used. – Jasarien Mar 22 at 16:21 2 UITableViewCellDeleteConfirmationControl Is not a public class.

– Jasarien Jul 28 at 6:58.

I don't know of any way to "move the delete button 10px to the left". However, you can animate the custom contents of your table cell around the static position of the unmovable delete button by listening for the willTransitionToState: message from a UITableViewCell sub-class see here. To quote the docs: Subclasses of UITableViewCell can implement this method to animate additional changes to a cell when it is changing state.

UITableViewCell calls this method whenever a cell transitions between states, such as from a normal state (the default) to editing mode. The custom cell can set up and position any new views that appear with the new state. The cell then receives a layoutSubviews message (UIView) in which it can position these new views in their final locations for the new state.

Subclasses must always call super when overriding this method. What you are looking for is the UITableViewCellStateShowingDeleteConfirmationMask value. This is one of those times where creating UITableViewCell subclass might be better, so from the controller you are just creating an instance of your custom cell.

Then the cell can just adjust itself like animateLeft and animateRight and handle the inner workings of adjusting its own subviews.

I haven't been able to change the actual look of the delete button, but you can change the text. Perhaps you can use this to get the effect you are looking for? Check out the following member of the UITableViewDelegate protocol: - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath Additionally, you can detect when the delete button is being displayed by subclassing UITableViewCell and overriding the the following: - (void)willTransitionToState:(UITableViewCellStateMask)state - (void)didTransitionToState:(UITableViewCellStateMask)state For either of these, the state mask will be UITableViewCellStateShowingDeleteConfirmationMask when the delete button is being displayed.

Hopefully these clues will point you in the right direction.

I don't know the final solution, but as far as I tried the following code might be useful. // subclass UITableViewCell - (void)willTransitionToState:(UITableViewCellStateMask)state { super willTransitionToState:state; if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableCellStateShowingDeleteConfirmationMask) { for (UIView *subview in self. Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { subview.

Alpha = 0; } } } } - (void)didTransitionToState:(UITableViewCellStateMask)state { super willTransitionToState:state; if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableCellStateShowingDeleteConfirmationMask) { for (UIView *subview in self. Subviews) { if (NSStringFromClass(subview class) isEqualToString:@"UITableViewCellDeleteConfirmationControl") { subview. Frame = CGRectMake(subview.frame.origin.

X - 10, subview.frame.origin. Y, subview.frame.size. Width, subview.frame.size.

Height); subview. UIView beginAnimations:@"anim" context:nil; subview. Alpha = 1; UIView commitAnimations; } } } }.

I am new in iPhone development and now I have simple question(may be not simple:). I have a UITableView, and in that UITableView I have for example 5 rows, every row has a UILabel and UIButton. What I want to do is to delete one element from the array when my button is pressed.

Button I create with tag, but that doesn't work. I do not want use didSelectRow; I want to delete an element from the array only if my button was pressed. (For example, if the third button was pressed I want to delete the third element of the array.

Using the standard delete button does not work for me.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions