Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iView动画在ios 5.1中不起作用_Iphone_Uitableview_Ios6_Ios5.1 - Fatal编程技术网

Iphone iView动画在ios 5.1中不起作用

Iphone iView动画在ios 5.1中不起作用,iphone,uitableview,ios6,ios5.1,Iphone,Uitableview,Ios6,Ios5.1,我的视野很开阔。我想在单元格加载到表中时制作动画。我是这样做的 -(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { CGRect tmpFrame; CGRect originalFrame; originalFrame = cell.frame; tmpFram

我的视野很开阔。我想在单元格加载到表中时制作动画。我是这样做的

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGRect tmpFrame;
    CGRect originalFrame;
    originalFrame = cell.frame;
    tmpFrame = cell.frame;
    tmpFrame = CGRectMake(0, -50, 320, 50);
    cell.frame = tmpFrame;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:5.0f];
    [UIView setAnimationBeginsFromCurrentState:YES];
    UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 320, 1)];
    separatorLineView.backgroundColor = [UIColor lightGrayColor];
    [cell.contentView addSubview:separatorLineView];
    cell.frame = originalFrame;
    [UIView commitAnimations];
}
此代码在iOS 6 iPhone simulator 6中运行良好,但在iOS 5.1 iPhone simulator 5.1中不起作用。

完成。 我把这个代码放进了

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

在返回单元格之前。

所以我知道您已经有了解决方案,但我可能建议使用动画块,除非您使其与旧版本兼容。无论如何,如果你不是,这可能会提供一种不同的方式来编写动画。我喜欢这样做,因为我觉得我对发生的事情有更多的控制权,更少的混乱

UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if(!cell){
    cell = [[UITableViewCell alloc]init];
}

CGRect movementFrame = cell.frame; // set the movement frame for modification
movementFrame.origin.y -= 50; //adjust only one variable instead of making a rect..

//Start your animation block. 
[UIView animateWithDuration:0.5
                      delay:0.0
                    options:UIViewAnimationCurveEaseOut
                 animations:^{
                     //Animation here
                     cell.frame = movementFrame; // Commit your changes basically
                 } completion:^(BOOL finished) {
                     //Completeion c

                 }];
太棒了!保重^^

编辑

去测试它,发现我漏掉了一个关键部分。我道歉。。但是,这段代码确实有效,并且将在一个分组表上制作动画,该表有一个充满小节的页面。

请遵循此链接。