I have placed the uiscrollview for viewcontroller. Then I have set my large size image as imageView in to the uiscrollView.Then I have set the some buttons into the imageView. In that imageview, I have called one method “showRestaurant”. But the selector failed to called the method.
Code:
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
float newScale = [imageScrollView zoomScale] * ZOOM_STEP;
CGRect zoomRect = [self zoomRectForScale:newScale withCenter:[gestureRecognizer locationInView:gestureRecognizer.view]];
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
[btn1 setImage:[UIImage imageNamed:@"restaurant.png"] forState:UIControlStateNormal];
UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
[btn2 setImage:[UIImage imageNamed:@"restaurant.png"] forState:UIControlStateNormal];
[imageScrollView zoomToRect:zoomRect animated:YES];
if(newScale==1.500){
btn1.frame = CGRectMake(2370.828125,1020.015625,35,34);
[btn1 addTarget:self action:@selector(showRestaurant) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:btn1];
btn2.frame = CGRectMake(2270.828125,1070.015625,35,34);
[btn2 addTarget:self action:@selector(showRestaurant) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:btn2];
}
}
-(void)showRestaurant{
NSLog(@"testing321");
}
Does the program flow even go inside the “if” ? That comparisons seem very weird (why do you convert floats to strings and then compare strings). Add a debug output inside your “if” to check whether you really end up in that block. Also, btn1 has the imageScrollView as target, btn2 has “self” as target. That also doesn’t look right.