2012-02-19 68 views
1

我的iPhone應用程序使用故事板將消息發送到父對象形式酥料餅

它有2個視圖控制器: - 主故事板視圖控制器 - 和酥料餅視圖控制器與一些對象在它

我」已經上了車主視圖控制器的按鈕,它創造編程我每次運行應用程序時:

*CGRect buttonFrame = CGRectMake(10., 10., 120., 50.); 

oneButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[oneButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"someImage.png", img]] forState:UIControlStateNormal]; 
[oneButton setTag:img]; 
[oneButton setFrame:buttonFrame]; 
[oneButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside]; 

[self.view addSubview:oneButton];* 

此按鈕的動作顯示我酥料餅的觀點那樣:

*- (void) pressButton:(id)sender { 

popoverViewController *popoverFrame = [self.storyboard instantiateViewControllerWithIdentifier:@"myPopoverView"]; 

popoverWithObjects = [[UIPopoverController alloc] initWithContentViewController:popoverFrame]; 

[popoverWithObjects presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; 

}* 

從現在的情況來看,我無法發送到我的按鈕任何消息或結果。 我想說我的程序按鈕(注意 - 我只有這個按鈕的發件人action:@selector(pressButton:))popover返回一些結果或popover中的對象的某些動作發送任何東西(例如字符串) 或換句話說當我與彈出視圖上的按鈕等任何對象進行交互時,我想更改父按鈕標題標籤

回答

0

您需要使用委託。看看我對這個類似問題的回答SO

編輯:鏈接到tutorial在故事板和委託模式的使用。我的原始答案SO

+0

ü知道,我試了一下。我無法在故事板應用程序中進行授權......無論如何,感謝您的答覆。而對於鏈接,它真正的幫助 – 2012-02-19 22:42:51

+0

如何使父對象代表團(按鈕在我的情況) – 2012-02-19 22:47:52

+0

我想你的appDelegate和其它類委託模式之間的混淆。儘管在Storyboard下appDelegate不可用,但使用委託模式回調仍然是有效的技術。在你的代碼,我猜「popoverViewController」或「myPopoverView」 – user523234 2012-02-20 02:58:45

0

如何在主視圖控制器上編寫函數以實現您想要的功能。然後從popover調用該函數? (即用「的SEGUE準備」送酥料餅的主視圖控制器的ID,然後使用該ID從酥料餅呼籲主視圖功能)