0

我现在正在开发一个相机应用程序,并且正在为我拍摄的照片使用图像滤镜效果。因此,当我拍照时,应该显示图片,并且在其下方,我想以水平滚动视图的形式显示该图片的十种不同的滤镜效果。

因此,如果我单击滚动视图中的任何一种滤镜效果,该特定效果应该应用于我拍摄的照片,并且该滤镜应用的图片应该显示在同一视图中。我还应该在图片上方有一个保存按钮,这样我就可以将它保存在我的私人应用程序目录中。(注意:不在默认图片库中)

我无法弄清楚我必须实现的确切代码或概念,即如何在水平滚动视图中插入图像或如何将图片保存到我的私有应用程序目录中。我正在使用iOS5。因此,非常感谢任何好的解决方案。

4

2 回答 2

3

它可能会帮助您处理水平滚动视图图像。

int scrollWidth = 180;
scrollview.contentSize = CGSizeMake(scrollWidth,110);    
int xOffset = 4;

for(int i = 0; i < [imgnamearr count]; ++i) 
{   
    UIImageView *img = [[UIImageView alloc] init];
    img.layer.masksToBounds = YES;
    img.frame = CGRectMake(5+xOffset,1, 145, 110);
    scrollview.contentSize = CGSizeMake(scrollWidth+xOffset,115); 
    [img addSubview:[UIImage imageNamed:[imgnamearr objectAtIndex:i]]];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(5+xOffset,0, 160, 110);
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    button.accessibilityIdentifier =[imgarr objectAtIndex:i]; 
    [scrollview addSubview:img];
    [scrollview addSubview:button];
    scrollview.contentSize = CGSizeMake(scrollWidth+xOffset,115);
    xOffset += 157;
}

- (IBAction)buttonClicked:(UIButton *)sender {
   UIImageView *bigimg = [[UIImageView alloc] init];
   bigimg.layer.masksToBounds = YES;
   bigimg.frame = CGRectMake(0,0, 200, 200);
   [bigimg addSubview:[UIImage imageNamed:sender.accessibilityIdentifier]];
   [self.view addSubview:bigimg];
}

编辑2:

-(void)Setthewholeview{

int row = 0;
int column = 0;


for(int i = 0; i < [imagearry count]; ++i) 
{

    UIView *uview =[[UIView alloc]initWithFrame:CGRectMake(column*155+5, row*126, 155, 125)];
    uview.layer.masksToBounds=YES;
    uview.backgroundColor = [UIColor whiteColor];



    UIImageView *detailback =[[UIImageView alloc] initWithFrame:CGRectMake(0,72,52,52)]; 
    detailback.image=[[UIImage alloc]init];
    detailback.image = [UIImage imageNamed:@"abc.png"];
    [uview addSubview:detailback];
    [detailback release];


    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(column*155+5, row*126, 155, 125);
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    button.tag = [[arrayname objectAtIndex:i]intValue]; 

    if (column == 1) // here set column which you want. If you wnat 2 column then set 1 here.
    {
        column = 0;
        row++;
    } else 
    {
        column++;
    }

    [self.scrollview addSubview:uview];
    [self.scrollview addSubview:button];
}

[self.scrollview setContentSize:CGSizeMake(320, (row+1) * 130)];

}
于 2012-10-20T04:32:59.493 回答
2

contentSize您可以通过将其高度设置为等于其高度来使滚动视图仅水平滚动bounds

您可以通过添加实例UIImageView作为滚动视图的子视图,在滚动视图中显示图像。

您可以使用UIImageJPEGRepresentationUIImagePNGRepresentation将图像转换为,并通过向其发送消息来NSData写入数据。writeToURL:options:error:

您可以使用 获取应用程序私有文档目录的 URL ,作为目录、域和URL-[NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error:]传递。NSDocumentDirectoryNSUserDomainMasknil

于 2012-10-20T04:17:33.587 回答