scrollView と 2 つのサブビューが関連付けられており、imageView と、イメージ ビューへの行を持つホットスポットを保持するボタン ビューがあります。ズームイン/ズームアウトして、それに応じてホットスポットを移動したい。私が抱えている問題は、必要な場所にホットスポットを保持できず、ここで解決策を見つけることができないことです.
これがviewDidLoadの私のコードです
- (void)viewDidLoad
{
[super viewDidLoad];
// set the tag for the image view
[imageView setTag:ZOOM_VIEW_TAG];
imageScrollView.delegate = self;
float sexy = [imageScrollView frame].size.height / [imageView frame].size.height;
initialZoom = sexy;
[imageScrollView setZoomScale:sexy animated:NO];
[imageScrollView setMinimumZoomScale:sexy];
[imageScrollView setContentInset:UIEdgeInsetsMake(-30, 0, 0, 0)];
scaleStart = imageScrollView.zoomScale;
buttonView = [[UIView alloc]init];
buttonView.frame = imageScrollView.frame;
[imageScrollView addSubview:buttonView];
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchDown];
[buttonView addSubview:button];
[button setTitle:@"Button x" forState:UIControlStateNormal];
button.frame = CGRectMake(200.0, 400.0, 520.0, 150.0);
imageView.center = self.view.center;
imageScrollView.maximumZoomScale = MAX_ZOOM_SCALE;
//setting an orientation notifier
UIDevice *device = [UIDevice currentDevice]; //Get the device object
[device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app
[nc addObserver:self //Add yourself as an observer
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:device];
}
残りのコードを実装しようとしています
- (void)scrollViewDidZoom:(UIScrollView *)aScrollView
aScrollView.zoomScale プロパティを使用すると運が悪くなります。
ボタンビューを適切な場所に移動します。私が抱えている問題は、ズームイン(フルズームイン)するとズームスケールが0.53454の値を取得し、(フル)ズームアウトすると0.37261の値を取得することですなぜこれが起こっているのですか?価値?
やりたいことはどうすればいいの?
ズームイン/ズームアウトするときにGoogleマップのようなものが必要で、ズームしなくてもスポットが所定の位置に保持されます。