Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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 图像视图动画问题_Iphone - Fatal编程技术网

Iphone 图像视图动画问题

Iphone 图像视图动画问题,iphone,Iphone,我已经完成了播放大量图像的效果,如下所示: NSInteger faceNum = 12; NSMutableArray *faceArray = [[NSMutableArray alloc] initWithCapacity:faceNum]; for (int i = 1;i<faceNum+1; i++) { NSString *facename = [[NSBundle mainBundle] pathForResource:[NSString st

我已经完成了播放大量图像的效果,如下所示:

NSInteger faceNum = 12;

NSMutableArray *faceArray = [[NSMutableArray alloc] initWithCapacity:faceNum];

for (int i = 1;i<faceNum+1; i++) {
    NSString *facename = [[NSBundle mainBundle] 
      pathForResource:[NSString   stringWithFormat:@"animationFace%d",i] ofType:@"png"];    
    UIImage *faceImage = [UIImage imageWithContentsOfFile:facename];    
    [faceArray addObject:faceImage];
}

 UIImageView *faceView = [[UIImageView alloc] 
   initWithFrame:CGRectMake(414, 157, 161, 124)];

 faceView.animationImages = faceArray;    
 faceView.animationDuration = 30;    
 faceView.animationRepeatCount = 0;

 [faceView startAnimating];    
 [self.view addSubview:faceView];    
 [faceView release];    
 [faceArray release];
NSInteger faceNum=12;
NSMutableArray*faceArray=[[NSMutableArray alloc]initWithCapacity:faceNum];

对于(int i=1;i,imageview startAnimating没有内置的淡入淡出功能。您可以通过手动设置彼此重叠的两个视图的alpha来实现这一点:

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.5f];

    imageviewToFadeOut.alpha = 0.0f;
    imageviewToFadeIn.alpha = 1.0f;

    [UIView commitAnimations];
和手动设置图像以替代这些UIView

[imageview setImage:image];
要递归调用此方法,请在方法本身内部使用类似于
[self-performSelector:@selector(methodname)with-object:afterDelay:
的内容

编辑:为清晰起见,指定递归以反复延迟调用此方法:

-(void)methodname {

.. (do your task)
[self performSelector:@selector(methodname) withObject:NULL afterDelay:10 ];
}

谢谢你的建议,我已经尝试过了,它会像预期的那样工作,但是如何实现总是重复它。似乎不能使用递归来实现这个方法,pic会在这个函数结束后显示。我尝试了一下(是的)递归到这个方法,在我的屏幕上没有变化。你能解释一下哪里出错了。你提到pic会在这个函数结束后显示(为什么不可以接受,函数不会花费可见的时间来完成),performselector会确保在“10”之后再次调用函数秒或秒的循环看起来也很奇怪