0

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

像这样的动画。

在此处输入图像描述

4

2 回答 2

0

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

UITableView 和 UITableViewCell 类都有一个名为:

editing

以及一个名为:

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

这两者都可用于将 UITableView/UITableViewCell 置于“编辑”模式。该属性可用于创建 UITableView/UITableViewCell 并在添加到视图层次结构之前将其设置为“编辑”模式。

然而,该方法虽然也可用于以编程方式实现相同的目的,但也可用于覆盖/增强 UITableView 的/UITableViewCell 的“编辑”行为。在这种情况下,UITableViewCell 可能会使用它来通知 UITableViewCell 所属的 UITableView 已将 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: ()

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

干杯。

于 2013-04-29T20:39:49.570 回答
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

其中 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

于 2012-06-06T09:46:00.867 回答