2014-09-04 46 views
-1

我正在使用分視控制器的應用程序,並支持所有的方向。但是在橫向模式下,我添加到detailview上的一個按鈕不起作用,所以我想知道如何找出當前的代表是什麼,以便我可以發送一個命令來執行該操作。我如何找到當前的代表?

更新

基本上按鈕(在detailVC)應該更改masterVC的VC?也許不是基本的,但它不應該很難做到?

+1

'self.delegate'? – sbarow 2014-09-04 08:43:08

+0

http://stackoverflow.com/a/5183349/1083921這會給你你的按鈕的動作和目標。 – Marc 2014-09-04 12:16:01

+0

[How to get UIButton Target,Action and Control events?](http://stackoverflow.com/questions/5182860/how-to-get-uibutton-target-action-and-control-events) – Alex 2014-09-05 10:19:59

回答

0

如果你的要求方向的情況下再

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 

if(orientation == 0) //Default orientation 
    //UI is in Default (Portrait) -- this is really a just a failsafe. 
else if(orientation == UIInterfaceOrientationPortrait) 
    //Do something if the orientation is in Portrait 
else if(orientation == UIInterfaceOrientationLandscapeLeft) 
    // Do something if Left 
else if(orientation == UIInterfaceOrientationLandscapeRight) 
    //Do something if right 

否則的話,我想更多地瞭解您的詳細問題(什麼確切的委託你找)

+0

嗯,我試圖找出委託的名稱,因爲我想添加一個方法,但有一大堆,所以我想知道是否有一種方法來記錄它? – AMAN77 2014-09-04 11:03:26

+0

這樣你就可以得到方向,並且可以根據方向對程序進行編程(詳細說明VC中的按鈕)。 – nikhil84 2014-09-04 12:21:06

+0

是的我有這樣的事情在AppDelegate中運行,但感謝您的嘗試。 – AMAN77 2014-09-04 13:57:43