2017-10-17 54 views
0

有誰知道如何在頂部以外的位置加載視圖控制器。這將類似於打開一個網頁部分的方式,即<a href="http://~mypage.html#target">Go to Target</a>IOS:在垂直座標處打開UIView

這不是一個tableview或web視圖,所以重點不是去表中的特定行或地方的web視圖。相反,它是一個普通的UIVIewController,關鍵是要在屏幕上的某個特定的垂直點上有相關的內容。

感謝您的任何建議。

編輯:我結束了使用以下,不優雅,我希望,但足夠:

-(void) raiseView:(float) float { 
    CGRect contextRect = self.view.bounds; 
    float boundsY = contextRect.origin.y; 
    contextRect.origin.y=boundsY+float; 
    self.view.bounds = contextRect; 
} 
+0

你到目前爲止嘗試過什麼?我假設你使用滾動視圖來包含你的內容? –

回答

0

我建議基於控制器的接口上進一步研讀,以及如何最好地利用共同的做法,以您的優點。

我的建議是依靠可用於UIViewController的演示文稿樣式。這將超過當前視圖呈現視圖控制器的例子:你需要爲你呈現的內容

MyViewController *controller = [[MyViewController alloc] init]; 
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;   
[currentViewController presentViewController:controller animated:YES completion:^{ 
     // Do whatever you need to here 
    }]; 

然後完成後,你可以做任何事情。在這裏,您可以簡單地將控制器視圖設置爲您想要的任何框架(用您的術語來說,任何您希望的頂點)。通過這種方式,您可以向用戶展示VC,並在頂部上顯示您需要的任何內容,其位置與上一個視圖的內容相關。

快樂編碼!