2013-04-13 35 views

回答

2

你可以嘗試,並把它添加到最頂層的應用程序窗口:

add.modalPresentationStyle = UIModalPresentationPageSheet; 
    [self presentViewController:add animated:YES completion:^{ 
     [[[[UIApplication sharedApplication] windows] lastObject] addSubview:button]; 
    }]; 

這應該給你正確的視圖,允許按鈕出現在模式的頂部和接收觸摸事件。

- 編輯 -

要定位按鈕,你可以嘗試這樣的事:

self.modalPresentationStyle = UIModalPresentationFormSheet; 
add.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentViewController:pvc animated:YES completion:^{ 
    CGRect parentView = pvc.view.superview.frame; 
    CGRect buttonFrame = button.frame; 
    buttonFrame.origin = CGPointMake(parentView.origin.x - buttonFrame.size.width/2.0f, parentView.origin.y - buttonFrame.size.height/2.0f); 

    [button setFrame:buttonFrame]; 
    [[[[UIApplication sharedApplication] windows] lastObject] addSubview:button]; 
}]; 

這將讓已經提出的modalView的框架。然後,您可以將您的按鈕的原點設置爲偏移並設置調整後的幀。

+0

很好的建議,你如何找到按鈕的位置? – chancyWu

+0

@chancy我已經更新了我的答案,希望能爲您提供解決方案。 –

+0

不錯的解決方案。謝謝。 – chancyWu

0

見,如果這個工程:

myPresentedView.clipsToBounds = NO;

這將允許按鈕繪製超出它的意見。這樣做的一個缺點是觸摸不會超出視界範圍,所以儘量不要將按鈕設置得太遠。

+0

這是行不通的。我已經嘗試過。該按鈕仍將被剪裁。 –

+1

clipsToBounds對頁面內顯示的視圖沒有影響,因爲它不能超出頁面範圍 – chancyWu

相關問題