0

我有一个表格视图,当我选择任何行时,它会显示该特定项目的详细信息。详细信息包含该项目的图片。现在我想在你点击后放大图片。请帮助,因为我是这个 iOS 领域的新手。

contentview = [[UIImageView alloc]init];
    [contentview setFrame:CGRectMake(10, 10, 300, 150)];
    [contentview setImage:[UIImage imageNamed:@"chicken tikka.png"]];
    [self.view addSubview: contentview];
    [contentview release];

    UIWebView *ingradients= [[UIWebView alloc]init];
    [ingradients setFrame:CGRectMake(10, 170, 300, 300)];
[ingradients loadHTMLString:@"<html><body><p style:color:red><strong>INGREDIENTS</strong></p><ul><li>One kg Chicken</li><li>Half kg Onion</li><li>200gm Tomato</li></ul></body></html>" baseURL:nil];

    ingradients.delegate=self;
    [self.view addSubview:ingradients];
4

1 回答 1

2

我认为这段代码对你有帮助

        imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, screenRect.size.height)];
        imageScrollView.maximumZoomScale = 2.50;
        imageScrollView.minimumZoomScale = 1.00;
        imageScrollView.clipsToBounds = YES;
        imageScrollView.delegate = self;
        [self.view addSubview:imageScrollView];

        imageView_temp = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, screenRect.size.height)];
        imageView_temp.contentMode = UIViewContentModeScaleToFill;
        imageView_temp.backgroundColor = [UIColor clearColor];
        [imageView_temp setUserInteractionEnabled:YES];
        originalImagePos = imageView_temp.center;
        [imageScrollView addSubview:imageView_temp];

        // scrollview content size
        imageScrollView.contentSize = CGSizeMake(imageView_temp.frame.size.width, imageView_temp.frame.size.height);

// call this method for to zoom in
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {

    return imageView_temp;
}

// call this method for to zoom out
-(void)resetImageZoom {

    NSLog(@"Resetting any image zoom");

    CGAffineTransform transform = CGAffineTransformMakeScale(1.0, 1.0);

    imageView_temp.transform = transform;

    [imageScrollView setContentSize:CGSizeZero];

    imageView_temp.center = originalImagePos;
}
于 2013-03-04T07:36:50.187 回答