I have created a method for example changeColor for calling the method we use
[self changeColor];
but how can I cancel these method ?
Edited :
here is my code I have several buttons which they add some image to the image view
- (void) setImagesFrame1 {
NSMutableArray *imageArray = [[NSMutableArray alloc]initWithCapacity:12];
for (int i = 0; i <= 12; i++) {
NSString *fileName = [NSString stringWithFormat:@"a%d.png",i];
UIImage *j = [UIImage imageNamed:fileName];
UIImageView *tempImage = [[UIImageView alloc]initWithImage:j];
[imageArray addObject:tempImage];
[self createPageWithImage:tempImage forPage:i];
}
}
- (void) setImagesFrame2 {
NSMutableArray *imageArray = [[NSMutableArray alloc]initWithCapacity:12];
for (int i = 0; i <= 12; i++) {
NSString *fileName = [NSString stringWithFormat:@"s%d.png",i];
UIImage *j = [UIImage imageNamed:fileName];
UIImageView *tempImage = [[UIImageView alloc]initWithImage:j];
[imageArray addObject:tempImage];
[self createPageWithImage:tempImage forPage:i];
}
}
and so on …
I call my methods with this action :
- (IBAction)openFrames:(UIButton *)sender {
[captureView addSubview:framesPreviewView];
[framesPreviewView sendSubviewToBack:captureView];
framesPreviewView.frame = CGRectMake(img.bounds.origin.x, img.bounds.origin.y, img.bounds.size.width, img.bounds.size.height);
//buttons
if (sender == frame1) { [self setImagesFrame1]; }
if (sender == frame2) { NSLog(@"frame2"); }
if (sender == frame3) { [self setImagesFrame3]; NSLog(@"frame3"); }
}
when I press frame1 button the images will be added to my view , the problem is when I press frame2 button the images of this method also add to my view I need avoid this situation , it means when I touch every button the methods of other button should be canceled
The last view on your subview array will be the image, You should use the method [view removeFrom superView];
However, to do that you need to use fast enumeration(for-In loop) over the subviews array.
If you want to be completely sure , you can check the retuned object, if it belongs to UIImageView Class. Then you should execute remaining statements in you setImages method.
Example: `
UIView *tempView;
`