Hi i have a uislider that changes the images in uiimageview.At first time it works great there is no delay . But when i click the button to publish (there is a modal view that opens) and close the modal view (this is the second time) the uiimageview delays that shown the images.i cant find why it gets slower:(
-(IBAction)sliderSlide:(UISlider *)aSlider {
float f=slider.value;
NSString *show=[NSString stringWithFormat:@"%.0f %%",f];
label2.text=show;
NSString *show1=[NSString stringWithFormat:@"%.0f",f];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"/Smiley_000%@.png", show1]];
float slid=slider.value;
if(slid>99)
{
[imageView1 setHidden:NO];
[imageView2 setHidden:YES];
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Smiley_00099.png"];
imageView.image = [UIImage imageWithContentsOfFile:fullpath];
secondarray=[NSArray arrayWithObjects:
[UIImage imageNamed:@"Rays_00000.png"],
[UIImage imageNamed:@"Rays_00001.png"],
[UIImage imageNamed:@"Rays_00002.png"],
[UIImage imageNamed:@"Rays_00003.png"],
[UIImage imageNamed:@"Rays_00004.png"],
[UIImage imageNamed:@"Rays_00005.png"],
[UIImage imageNamed:@"Rays_00006.png"],
[UIImage imageNamed:@"Rays_00007.png"],
[UIImage imageNamed:@"Rays_00008.png"],
[UIImage imageNamed:@"Rays_00009.png"],
nil];
imageView1.animationImages = secondarray;
// How many seconds it should take to go through all images one time.
imageView1.animationDuration = 0.5;
// How many times to repeat the animation (0 for indefinitely).
imageView1.animationRepeatCount = 0;
[imageView1 startAnimating];
}
else if (slid<1)
{
[imageView2 setHidden:NO];
[imageView1 setHidden:YES];
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Smiley_0000.png"];
imageView.image = [UIImage imageWithContentsOfFile:fullpath];
firstarray=[NSArray arrayWithObjects:
[UIImage imageNamed:@"Teardrop_00000.png"],
[UIImage imageNamed:@"Teardrop_00001.png"],
[UIImage imageNamed:@"Teardrop_00002.png"],
[UIImage imageNamed:@"Teardrop_00003.png"],
[UIImage imageNamed:@"Teardrop_00004.png"],
[UIImage imageNamed:@"Teardrop_00005.png"],
[UIImage imageNamed:@"Teardrop_00006.png"],
[UIImage imageNamed:@"Teardrop_00007.png"],
[UIImage imageNamed:@"Teardrop_00008.png"],
[UIImage imageNamed:@"Teardrop_00009.png"],
[UIImage imageNamed:@"Teardrop_00000.png"],
[UIImage imageNamed:@"Teardrop_00000.png"],
[UIImage imageNamed:@"Teardrop_00000.png"],
[UIImage imageNamed:@"Teardrop_00000.png"],
[UIImage imageNamed:@"Teardrop_00000.png"],
nil];
imageView2.animationImages = firstarray;
// How many seconds it should take to go through all images one time.
imageView2.animationDuration = 0.8;
// How many times to repeat the animation (0 for indefinitely).
imageView2.animationRepeatCount = 0;
[imageView2 startAnimating];
[self.view addSubview:imageView2];
}
else
{
[imageView1 setHidden:YES];
[imageView2 setHidden:YES];
[imageView1 stopAnimating];
[imageView2 stopAnimating];
}
[[NSUserDefaults standardUserDefaults] setFloat:slid forKey:@"slider"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
this is my code if u can see why performance decrease in the second time i slide the slider pls tell me
edit 1:
i cancel some animations and slider get back to its speed but now the pictures are sticking slider okey but pictures are slow then the first time.
My alertview makes the application (slider and images) goes slower so i remove it and it work just fine.