2012-10-23 61 views
1

在iOS 6中,您有Unwinding Segue返回到先前的視圖控制器。iOS處理UIBarButtonItem的方式展開Segue

我現在正在與故事板一起工作,來確定這個事情。我在iOS 5上,我沒有展開塞恩。

圖片說明了情況: enter image description here

在第三個窗口(我認爲它的正式名稱叫故事)有一個完成按鈕。

如何使該按鈕返回屏幕上的文本對象並返回到窗口2? 在那裏,我的窗口2桌子應該refries,但這是超出了這個問題的範圍。

我所做的是在ThirdWindowViewController中實現IBOutlet(讓我們這樣稱呼它),它與IBAction方法相關聯。

@property (nonatomic, strong) IBOutlet UITextView* textView; 

@property (nonatomic, strong) Note* note; 

@property (nonatomic, retain) IBOutlet UIBarButtonItem* doneButton; 

- (void) configureView; 
- (IBAction) doneAction:(id)sender; 
- (BOOL) prepareNoteForTransition; 

EDIT_01

當湯姆寫的,你需要一個代表。這就是我真正做到的方式,用上面提到的方法。我只是認爲有更多的蘋果專用的方式來做到這一點,就像Segues。或一些替代品。

謝謝你們。

回答

2

您想爲呈現視圖的「故事」的視圖控制器設置一個委託財產控制器:

NotesViewController.m

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([segue.identifier isEqualToString:@"showStoryViewController"]) { 
     [segue.destinationViewController setDelegate:self]; 
    } 
} 

- (void)storyViewControllerDidPressDoneWithText:(NSString *)text note:(Note *)note 
{ 
    self.note = [NSString stringWithString:note]; 
    [self dismissViewControllerAnimated:YES completion:NULL]; 
} 

Story.m

- (IBAction)doneAction:(id)sender 
{ 
    [self.delegate storyViewControllerDidPressDoneWithNote:self.textView.text note:self.note]; 
} 

也請確保#import "NotesViewController.h"Story.h

+0

所以這是... –

0

我不知道我理解得很好,但你可以從你Done鍵畫一個原因請看第二視圖控制器和執行prepareForSegue:。通過這種方式,您可以將最後一個視圖控制器的任何信息發送到目標控制器。

2

我也不敢肯定明白你的問題,但如果你想要做按鈕的動作回去就寫[self.navigationController popViewControllerAnimated:YES];