繁体   English   中英

ios-iPhone:像本地ios闹钟应用程序一样进行编辑时,如何创建动画UItableviewcell

[英]ios - iphone: How to create animation UItableviewcell when edit like native ios alarm clock app

我已经制作了一个类似于iPhone / iPod上的默认闹钟的闹钟。 但是我不知道如何像本地ios时钟应用程序一样编辑时如何创建动画UItableviewcell。请帮助我。 谢谢

这样的动画。

在此处输入图片说明

[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

其中UITableViewRowAnimation可以是以下之一:

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

我看到的是控件被隐藏了。

UITableView和UITableViewCell类都具有一个称为的属性:

editing

以及称为:

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

这两个都可用于将UITableView / UITableViewCell置于“编辑”模式。 该属性可用于创建UITableView / UITableViewCell并将其设置为“编辑”模式,然后再添加到视图层次结构中。

但是,该方法虽然也可以用于通过编程实现相同的目的,但也可以用于覆盖/增强UITableView / UITableViewCell的“编辑”行为。 在这种情况下,可以由UITableViewCell使用它,通过UITableViewCell已被设置为“编辑”模式这一事实,通过UITableViewCell属于其自己的UITableView进行通知:

- (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: ()

因此,如果这是Apple提供的UTableViewCell类型之一。 为了使我们的任何控件成为UITableViewCell的一部分,需要将其添加到由UITableViewDataSource提供的UITableView方法中的UITableViewCell的内容视图中:

- (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: ()

我希望这能回答您的问题。

干杯。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM