0

I have make a alarm clock like default alarm clock on iphone/ipod. But I dont know How to create animation UItableviewcell when edit like native ios clock app.Please help me. thanks

Animation like this.

enter image description here

Guru
  • 21,652
  • 10
  • 63
  • 102

2 Answers2

0
[tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];

http://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/reloadSections:withRowAnimation:

where UITableViewRowAnimation ca be one of these:

typedef enum {
UITableViewRowAnimationFade,
UITableViewRowAnimationRight,
UITableViewRowAnimationLeft,
UITableViewRowAnimationTop,
UITableViewRowAnimationBottom,
UITableViewRowAnimationNone,
UITableViewRowAnimationMiddle,
UITableViewRowAnimationAutomatic = 100
} UITableViewRowAnimation;

http://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITableViewRowAnimation

Guntis Treulands
  • 4,764
  • 2
  • 50
  • 72
  • Thank for your comment. I was tested it but animation not like cell on default alarm clock app – Tran Ngoc Hung Jun 06 '12 at 11:28
  • Yes. I do . Please see my picture http://i594.photobucket.com/albums/tt22/hungknorton/ScreenShot2012-06-06at35954PM.png . I mean when use click edit UIswitch will disappear and accessory checkmark appear. It similar Alarm clock default on ios – Tran Ngoc Hung Jun 06 '12 at 12:04
  • yes. I must make animation like this with custom uitableviewcell and uiswitch. – Tran Ngoc Hung Jun 06 '12 at 12:13
  • I'm thinking that they are just changing tableviewcell accessory view from cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; to custom accessoryview with uiswitch. Can You test that? – Guntis Treulands Jun 06 '12 at 12:34
  • but using animations to change. It should somehow animate. Other possibility is that you use DisclosureIndicator as a custom accessory view (you get the image and place it yourself)- then on entering edit mode - you move them both, and fade out one of them. – Guntis Treulands Jun 06 '12 at 13:16
0

What I see happening is that the control is being hidden.

Both the UITableView and the UITableViewCell classes have a property called:

editing

as well as a method called:

- (void) setEditing : (BOOL) editing animated : (BOOL) animated;

Both of these may be used to place a UITableView/UITableViewCell in "editing" mode. The property may be used to create a UITableView/UITableViewCell and set it to "editing" mode before being added to the view hierarchy.

However, the method, while it may also be used to achieve the same thing programmatically, may also be used to override/enhance a UITableView's/UITableViewCell's "editing" behavior. In this case, it may be used by the UITableViewCell to be notified, by the very own UITableView of which the UITableViewCell is part, of the fact that the UITableView has been set to "Editing" mode:

- (void) setEditing : (BOOL) editing animated : (BOOL) animated
{ // setEditing:animated: ()
    mySwitchView = [[self contentView] viewWithTag : 100];
    CGFloat alphaValue = editing ? 0.0f : 1.0f;

    [UIView animateWithDuration : 3.0f
                     animations : ^(void)
                                 {
                                     [mySlideView setAlpha : alphaValue];
                                 }
} // setEditing:animated: ()

Therefore, if this were one of the UTableViewCell types provided by Apple. In order to have any control of ours be part of the UITableViewCell, it needs to be added to the UITableViewCell's content view in the UITableView's method provided by the UITableViewDataSource:

- (UITableViewCell*) tableView : (UITableView*) cellForRowAtIndexPath : (NSIndexPath*) indexPath
{ // tableView:cellForRowAtIndexPath: ()
    static cellIdentifier = @"cell-identifier";

    UISwitchView*    switchView = nil;
    UITableViewCell* cell       = [tableView dequeueReusableCellWithIdentifier : cellIdentifier];

    if (cell == nil)
    { // if ()
        switchView = [[UISwitchView     alloc] initWithFrame : CGRectZero];
        cell       = [[[UITableViewCell alloc] initWithStyle : UITableViewCellStyleDefault
                                             reuseIdentifier : cellIdentifier] autorelease];
        [switchView setTag : 100];
        [[cell contentView] addSubview : switchView];

        [switchView release];

        switchView = nil;
    } // if ()

    return (cell);
} // tableView:cellForRowAtIndexPath: ()

I do hope this answers your question.

Cheers.