Hi guys, this is my first post here, and I'm pretty new to programming on iphone. I just started about a month ago and only dealt with small training types of applications, but anyway, my question
I currently have a scrollable and scalable UIScrollView that loads a UIImageView view, and I want to add some UIButtons over the image view, but when I zoom in and out the whole group (buttons and image) zoom togeather.
if I add UIButtons to my UIScrollView and zoom in, the image scaling and buttons stay in their original place
if I add UIButtons to my UIImageView, they will scale correctly and the buttons arent bigger. IE they lose their interactivity.
later add a lot of elements to the array and add them.
I would appreciate any help I can get.
this is part of my mainViewController.m
- (void)viewDidLoad
{
[scrollView2 setBackgroundColor: [UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES;
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scroll2ImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bigNH.jpg"]];
[scrollView2 addSubview:scroll2ImageView];
[scrollView2 setContentSize:CGSizeMake(scroll2ImageView.frame.size.width, scroll2ImageView.frame.size.height)];
scrollView2.minimumZoomScale = .5;
scrollView2.maximumZoomScale = 3;
scrollView2.delegate = self;
[scrollView2 setScrollEnabled:YES];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect newSize = CGRectMake(658, 435, 50, 50);
myButton.frame = newSize;
[myButton setImage:[UIImage imageNamed:@"redStop.png"] forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[scroll2ImageView addSubview:myButton];
[redLineArray addObject:myButton];
[scroll2ImageView release];
}
source
share