0
我想知道如何使用委託方法將按鈕從隱藏更改爲取消隱藏。我之前沒有使用應用程序代表,他們看起來很混亂。Xcode - 如何使用委託方法隱藏取消隱藏按鈕
我想知道如何使用委託方法將按鈕從隱藏更改爲取消隱藏。我之前沒有使用應用程序代表,他們看起來很混亂。Xcode - 如何使用委託方法隱藏取消隱藏按鈕
確定你有VC1 - > VC2
你必須在VC2,使在VC1隱藏按鈕buttonTohide
從動作(someAction)
1.增加標頭中的代表協議定義
@protocol CustomDelegate <NSObject>
-(void)hideUnhidebutton:(BOOL)value;
@end
2. in VC1.h使VC1成爲代表接收者
@interface VC1<CustomDelegate>
3. VC1.m 實現該方法來執行buttonhide
-(void)hideUnhidebutton:(BOOL)value
{
[self.buttonTohide setHidden:value];
}
4. 在VC2 加載委託變量作爲屬性
@property (nonatomic, strong) id<CustomDelegate> delegatePpty;
在VC2 .m在某事你必須隱藏VC1中的按鈕,所以調用刪除門方法
-(void)someAction
{
[self.delegatePpty hideUnhidebutton:YES];//Call the delegate method to execute
}
,它會隱藏編碼:)
我的可能是stubid但出於某種原因,我得到一個壞的接收器類型爲void錯誤,您可以幫助you.Happy按鈕??? – 2013-03-08 16:39:00