|
|
|
How to array of images delete specific image from imageview with scrollview in ios/iphone |
|
|
|
|
|
|
|
You have screenshot ?
|
|
|
|
|
Date :
2013-11-24 11:07:19 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Image galley
which image you select go to next page show that particular image
This is my code for particular image and scroll next image
Code (Objective-C)
arrayOfImages = [[NSMutableArray alloc]init];
NSString *stringPath = [NSString stringWithFormat:@"%@/images/",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)objectAtIndex:0]];
NSArray *filePathsArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:stringPath error:nil];
for(i=0;i<[filePathsArray count];i++)
{
NSString *strFilePath = [filePathsArray objectAtIndex:i];
if ([[strFilePath pathExtension] isEqualToString:@"jpg"] || [[strFilePath pathExtension] isEqualToString:@"png"] || [[strFilePath pathExtension] isEqualToString:@"PNG"])
{
NSString *imagePath = [stringPath stringByAppendingPathComponent:strFilePath];
NSData *data = [NSData dataWithContentsOfFile:imagePath];
if(data)
{
UIImage *image = [UIImage imageWithData:data];
[arrayOfImages addObject:image];
}
}
}
int x = 0;
int y = 0;
for (j=0; j<arrayOfImages.count;j++){
imageView1=[[UIImageView alloc]initWithFrame:CGRectMake(x,y,320,400)];
imageView1.image=[arrayOfImages objectAtIndex:j];
[imgscrl addSubview:imageView1];
x=x +320;
}
[imgscrl setContentOffset:CGPointMake((_myInteger*320), 400)];
imgscrl.contentSize=CGSizeMake(x, y);
imgscrl.pagingEnabled=TRUE;
I want how to delete that particular image.
|
|
|
|
|
Date :
2013-11-26 12:39:36 |
By :
vishwa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1. find image position,index in array for remove
get page in uiscrollview
int page = scrollView.contentOffset.x / scrollView.frame.size.width;
2. remove objects in nsarray
[anArray removeObjectAtIndex: page];
3. remove uiimageview in uiscrollview
for (uiimageview *subview in [uiscrollview subviews])
{
if (subview.tag == 1000 + page)
{
[subview removeFromSuperview];
}
}
4. set contentsize and contentoffset in uiscrollview
CGSizeMake(320.0f * [anArray count], 400.0f)
CGPointMake(320.0f * page, 400.0f)
hope to help you, unless you want to remove from image file .png/.jpg/
|
|
|
|
|
Date :
2013-11-26 18:01:15 |
By :
winterlovesong |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thanks now working perfect.
|
ประวัติการแก้ไข 2013-11-27 10:25:03 2013-11-27 11:10:46
|
|
|
|
Date :
2013-11-27 10:22:43 |
By :
vishwa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
more code for smooth,
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.50];
scrollview.contentOffset = CGPointMake(320.0f * page, 400.0f);
[UIView commitAnimations];
hope to help you
|
|
|
|
|
Date :
2013-11-27 11:43:15 |
By :
winterlovesong |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|