0

该示例非常简单,将一堆UIImageViews 作为子视图添加到 a UIScrollView

for(NSDictionary *dict in info) {
    UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
    imageview.frame = CGRectMake(x, 0, 91, 91);

    [self.scrollView addSubview:imageview];
        x+=95;
        [self.scrollView setContentSize:CGSizeMake(x, 91.0)];
        //define gestures
        //single tap for wide display
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(wideDisplay:)];
        imageview.userInteractionEnabled = YES;
        [imageview addGestureRecognizer:singleTap];
}

单击 a 后UIImageView,它被发送到wideDisplay:方法以广泛显示:

-(void)wideDisplay:(UITapGestureRecognizer*)gesture{

    UAModalPanel *wideScreen = [[UAModalPanel alloc] initWithFrame:self.view.bounds];
    wideScreen.padding = UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0);

    self.imageView = [[UIImageView alloc]init];
    self.imageView = (UIImageView*)gesture.view;
    self.imageView.frame = CGRectMake(20, 20, 790, 500);

    [wideScreen.contentView addSubview:self.imageView];
    [self.view addSubview:wideScreen];    

}

将 imageView添加到模态视图后,它UIImageView会从滚动视图子视图中删除。imageView 是一个强大的属性,但尽管如此,它似乎在添加到自定义模式视图后失去了引用,如何防止它在选择后从滚动视图中删除?

4

1 回答 1

0

你不是在self.imageView每次调用时都在处理和创建-wideDisplay:吗?

于 2013-11-01T20:42:52.500 回答