I have:
- UIView to contain an ImageView
- UIScrollView add in this UIView to enable Scroll (Which did not work)
- I have an AlertView to pop up this UIView
- I added UIImageView, and UIScrollView as subview of UIView
Every time I run the code, there's no sign of the existence of scrollview. I don't know why.
Here is the code:
- (void) handleImageTap:(UIGestureRecognizer *)gestureRecognizer {
//create image
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 500, 500)];
//create a scrollview to contain the uiview above
UIScrollView* scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,480)];
scrollview.showsVerticalScrollIndicator=YES;
scrollview.scrollEnabled=YES;
scrollview.userInteractionEnabled=YES;
[scrollview setDelegate:self];
[scrollview setBouncesZoom:YES];
scrollview.contentSize = CGSizeMake(500,500);
//create a view to show picture
UIView *demoView = [[UIView alloc] init];
if(gestureRecognizer.view == _firstImageView){
UIImage *image = [UIImage imageNamed:_photoDetailModel[1]];
[imageView setImage:image];
CGSize imageSize = imageView.image.size;
[demoView setFrame: CGRectMake(0, 0, 290, 200)];
// [demoView setFrame: CGRectMake(0, 0,imageSize.width, imageSize.height)];
}else{
UIImage *image = [UIImage imageNamed:_photoDetailModel[2]];
[imageView setImage:image];
CGSize imageSize = imageView.image.size;
[demoView setFrame: CGRectMake(0, 0, 290, 200)];
}
//add imageview
[demoView addSubview:imageView];
//add scollview
[demoView addSubview:scrollview];
//create a pop up view to contain the above uiview
CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];
// Add some custom content to the alert view
[alertView setContainerView: demoView];
// Modify the parameters
[alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"Close", nil]];
// You may use a Block, rather than a delegate.
// [alertView setOnButtonTouchUpInside:^(CustomIOS7AlertView *alertView, int buttonIndex) {
// NSLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
// [alertView close];
// }];
[alertView setUseMotionEffects:true];
// And launch the dialog
[alertView show];
}