2014-03-05 53 views
0

我有一個記錄按鈕,當按下時,我想隱藏說明按鈕。當另一個UI按鈕被按下時隱藏一個UI按鈕

這裏的備案按鈕的代碼:

// Create custom overlay 
// Create instruction/record button 
// Add instruction/record button to custom overlay 
[_videoRecordBtn addTarget:self action:@selector(startVideoRecord:) forControlEvents:UIControlEventTouchUpInside]; 

所以在startVideoRecord我應該是這樣:

-(IBAction)startVideoRecord:(id)sender{ 
    [_instru setHidden:YES]; 
    // start recording... 
} 

但我不知道怎麼過來startVideoRecord通過_instru按鈕。

+1

讓你的''instru''是一個類的屬性。然後你可以通過'self.instru''訪問它,並將它設置爲''self.instru.hidden = YES;'''在你的課程的任何地方。 – damirstuhec

+1

你能解釋__pass _instru按鈕來啓動VideoRecord__嗎? –

+1

你可以使_instru按鈕在全局上定義在.h文件上 – morroko

回答

1

屬性添加到您的視圖控制器,以保持你的instructionsButton參考:

@property (nonatomic, strong) UIButton *instructionsButton; 

當你創建你的instructionsButton時,將它分配給thi的財產。

然後你可以在你的ViewController任何地方通過這個屬性訪問按鈕self. instructionsButton

所以,你的操作方法是這樣的:

-(IBAction)startVideoRecord:(id)sender{ 
    self.instructionsButton.hidden = YES; 
    // start recording... 
} 
1

您可以通過2路做..

1路 - >您設置的tag of instructions button

,並使用此

-(IBAction)startVideoRecord:(id)sender{ 

UIButton *instruBtn = (UIButton*)[self.view viewWithTag:your button tag]; 


instruBtn.hidden = YES; 

// start recording... 
} 

第二路 - >你讓屬性您的指示按鈕,使用這樣的

-(IBAction)startVideoRecord:(id)sender{ 

    self.instruBtn.hidden = YES; 

    // start recording... 
    } 
相關問題