1
我有一個滾動視圖和連接在該一個ImageView的兩個子視圖和一個按鈕查看其保持一些熱點具有線圖像視圖。我想放大/縮小並相應地移動熱點。我遇到的問題是我無法將熱點保留在我想要的位置,並且無法在此處找到解決方案。的UIScrollView和zoomScale
這裏是我在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爲什麼會發生這種情況,我不會再次得到第一個值?
我怎麼可以做我想做的事?
我想要的東西,像谷歌地圖時,放大/縮小和地方點守在原地,而不進行縮放自己。