我正在一個視圖控制器,其中包含兩個UIImageView
s。底部圖像視圖保存照片(由用戶拍攝或選擇)。第二個圖像視圖位於此之上,佔據了整個屏幕。使用點和多個圖像視圖
第二個圖像視圖包含一個指針(下例中爲綠點)。它用作可移動視圖,可以在屏幕上定位。它的用途是在背後的照片上標記一個位置/點。
在肖像這工作正常,底部圖像視圖設置爲圖像=方面填充。因此拍攝的照片佔據整個屏幕。
在橫向方向,這不起作用。我可以在下面
解釋與
嚴重繪製圖像更好一點作爲一個例子,如果用戶選擇在縱向視圖的點(由綠點示出)大概位置是220,380。
但是,如果同一位置上的風景會不會對後面的照片相同的位置。
該點將轉化爲更多像280,300。
所以,問題是......當VC是定向的風景,我怎麼確定(從底部的圖像視圖中),圖像的高度和寬度,制定出的相同點?
或者是否有另一種方法/方法來完成此?
-------編輯---------- 我已經創建了一個測試應用程序,只有這個功能。我具有與上面詳述的相同的設置。我已將日誌添加到視圖,並將方向更改爲橫向。下面是我使用的日誌:
NSLog(@"bottom image view width: %f",self.photoImageView.frame.size.width); NSLog(@"bottom image view height: %f",self.photoImageView.frame.size.height); NSLog(@"bottom image view frame bounds X: %f",self.photoImageView.frame.origin.x); NSLog(@"bottom image view frame bounds Y: %f",self.photoImageView.frame.origin.y); NSLog(@"bottom image view bounds X: %f",self.photoImageView.bounds.origin.x); NSLog(@"bottom image view bounds Y: %f",self.photoImageView.bounds.origin.y); NSLog(@"---------BOTTOM IMAGE VIEW IMAGE DETAILS---------"); NSLog(@"bottom image view image width: %f",self.photoImageView.image.size.width); NSLog(@"bototm image view image height: %f",self.photoImageView.image.size.height); NSLog(@"bottom image view image frame bounds X: %f",self.photoImageView.image.accessibilityFrame.origin.x); NSLog(@"buttom image view image frame bounds Y: %f",self.photoImageView.image.accessibilityFrame.origin.y);
這些結果如下:
2013-07-30 14:58:23.013 SelectPhotoViewTest[3414:c07] ---------VIEW DETAILS--------- 2013-07-30 14:58:23.014 SelectPhotoViewTest[3414:c07] ---------BOTTOM IMAGE VIEW DETAILS--------- 2013-07-30 14:58:23.015 SelectPhotoViewTest[3414:c07] bottom image view width: 480.000000 2013-07-30 14:58:23.016 SelectPhotoViewTest[3414:c07] bottom image view height: 268.000000 2013-07-30 14:58:23.016 SelectPhotoViewTest[3414:c07] bottom image view frame bounds X: 0.000000 2013-07-30 14:58:23.017 SelectPhotoViewTest[3414:c07] bottom image view frame bounds Y: 0.000000 2013-07-30 14:58:23.018 SelectPhotoViewTest[3414:c07] bottom image view bounds X: 0.000000 2013-07-30 14:58:23.018 SelectPhotoViewTest[3414:c07] bottom image view bounds Y: 0.000000 2013-07-30 14:58:23.019 SelectPhotoViewTest[3414:c07] ---------BOTTOM IMAGE VIEW IMAGE DETAILS--------- 2013-07-30 14:58:23.019 SelectPhotoViewTest[3414:c07] bottom image view image width: 258.000000 2013-07-30 14:58:23.019 SelectPhotoViewTest[3414:c07] bototm image view image height: 480.000000 2013-07-30 14:58:23.020 SelectPhotoViewTest[3414:c07] bottom image view image frame bounds X: 0.000000 2013-07-30 14:58:23.021 SelectPhotoViewTest[3414:c07] buttom image view image frame bounds Y: 0.000000
如何從這些結果中得到,以確定中心點是相對於底部圖像座標?
謝謝,我認爲第二個選項將是最好的實施。但是,兩者都可以工作。我選擇第二個的原因是因爲頂部圖像視圖使用了過大的圖像。這是爲了說明imageview的移動,並確保視圖總是在屏幕上,當完全移動到一側時。然而,我不確定你在答案中是如何計算出這些例子的,你能否詳細說明一下?我不確定如何從頂部圖像視圖的中心點到底部圖像的圖像座標以及使用的方法。 – StuartM
頂部圖像的中心點與整個屏幕還是自己的超級視圖有關? – robinkunde
這將是在屏幕上的uiimageview的中心點 – StuartM