由於某種原因,與我的UIButton的交互僅適用一次。我已經嘗試通過IBAction,並通過IBOutlet與「addTarget」。我不知道爲什麼。按鈕觸摸僅適用於一次
語境:
BaseViewController
- (IBAction) button_touched:(id)sender; //<-- Declared here, but not implemented
- (void)userInputReceived:(BOOL)bSuccess; //<-- Declared here, but not implemented
ViewController1:BaseViewController
- (IBAction) button_touched:(id)sender; //<-- Implemented here
- (void)userInputReceived:(BOOL)bSuccess; //<-- Implemented here
而且,這是我嘗試 「addTarget」 但是,這並不工作,要麼(第一觸摸作品,但不是第二個)
在「button_touched」方法ViewController1(VC1),我作出這樣到另一個類的電話:
[someOtherClassObject doSomethingWithMyView:self];
那類簡單地彈出一個消息框,獲取用戶輸入,然後調用回到了的ViewController:
(內部SomeOtherClass) :
-(void)doSomethingWithMyView:(BaseViewController*)vc
{
// Do Something
[vc userInputReceived:TRUE];
}
一旦這個工作流執行一次,按鈕觸摸從來沒有要求再次「button_touch」的方法。不管我做什麼,我都無法再讓這個被調用。
在一個流行的BBS論壇上的一個討論中,有人提到這樣的問題可能是由於沒有你認爲你做的對象(vc1)而導致的,而是它的另一個實例。所以,我在很多地方記錄了像NSLog這樣的實例(「instance:%p」,self),它總是一樣的。
任何想法,不勝感激。這非常令人沮喪。
您可以發佈所有的代碼從button_touched行:方法?另外,您是如何將您的按鈕連接到IBAction的,以及尋找什麼樣的觸摸? – Jamie