我正在使用动画方法在 UIimageView 中实现幻灯片放映:
I'm using animation method of for implementing slide show in UIimageView as:
mainSlideShowImageView.animationImages=images;
mainSlideShowImageView.animationDuration = 75.00;
mainSlideShowImageView.animationRepeatCount = 0; //infinite
[mainSlideShowImageView startAnimating];
现在,我想知道哪个图像当前在图像视图屏幕上.
Now, what I want is to know which image is currently on image view screen.
我该怎么做?
如果不可能,也请告诉.
If it is not possible please tell that too.
'images' 这里是 UIImage 数组.
'images' here is array of UIImage.
AFAIK,没有返回 imageview 的当前图像的方法,但是我已经为此创建了一个解决方法....
AFAIK, there is no method which returns imageview's current image , however I have created a workaround for this....
array= [NSArray arrayWithObjects:[UIImage imageNamed:@"1.jpg"],[UIImage imageNamed:@"2.jpg"],[UIImage imageNamed:@"3.jpg"],[UIImage imageNamed:@"4.jpg"],[UIImage imageNamed:@"5.jpg"],nil];
mainSlideShowImageView.animationImages= array;
mainSlideShowImageView.animationDuration=15.0;
i=0;
timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(increase) userInfo:nil repeats:YES];
[mainSlideShowImageView startAnimating];
-(void)increase
{
i++;
if (i>4) {
i=0;
}
}
-(void)getimage
{
UIImage* im = [array objectAtIndex:i];
// im is the current image of imageview
}
我在这里拍摄了 5 张图像,动画持续时间为 15 ,这意味着图像将每 3 秒更改一次,所以我让计时器每 3 秒触发一次……并且由于数组包含 5 张图像……所以如果'i' 超过 4 我在方法增加中将其放回 0
I have taken 5 images here and animation duration of 15 , that means image will change at every 3 seconds, so I have kept timer to fire at every 3 seconds ... and since array contains 5 images ... so if 'i' goes beyond 4 I have put it back to 0 in method increase
这篇关于从动画 UIImageView 获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!