久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='uEDX3'><style id='uEDX3'><dir id='uEDX3'><q id='uEDX3'></q></dir></style></legend>

    <small id='uEDX3'></small><noframes id='uEDX3'>

    <tfoot id='uEDX3'></tfoot>
    • <bdo id='uEDX3'></bdo><ul id='uEDX3'></ul>
    <i id='uEDX3'><tr id='uEDX3'><dt id='uEDX3'><q id='uEDX3'><span id='uEDX3'><b id='uEDX3'><form id='uEDX3'><ins id='uEDX3'></ins><ul id='uEDX3'></ul><sub id='uEDX3'></sub></form><legend id='uEDX3'></legend><bdo id='uEDX3'><pre id='uEDX3'><center id='uEDX3'></center></pre></bdo></b><th id='uEDX3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uEDX3'><tfoot id='uEDX3'></tfoot><dl id='uEDX3'><fieldset id='uEDX3'></fieldset></dl></div>

        試圖在視圖控制器之間傳遞數據

        Trying to pass data between viewControllers(試圖在視圖控制器之間傳遞數據)

          <tbody id='AEOFk'></tbody>
        <i id='AEOFk'><tr id='AEOFk'><dt id='AEOFk'><q id='AEOFk'><span id='AEOFk'><b id='AEOFk'><form id='AEOFk'><ins id='AEOFk'></ins><ul id='AEOFk'></ul><sub id='AEOFk'></sub></form><legend id='AEOFk'></legend><bdo id='AEOFk'><pre id='AEOFk'><center id='AEOFk'></center></pre></bdo></b><th id='AEOFk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AEOFk'><tfoot id='AEOFk'></tfoot><dl id='AEOFk'><fieldset id='AEOFk'></fieldset></dl></div>
          <legend id='AEOFk'><style id='AEOFk'><dir id='AEOFk'><q id='AEOFk'></q></dir></style></legend>
          • <small id='AEOFk'></small><noframes id='AEOFk'>

                  <bdo id='AEOFk'></bdo><ul id='AEOFk'></ul>
                  <tfoot id='AEOFk'></tfoot>
                  本文介紹了試圖在視圖控制器之間傳遞數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我在 NavigationController 中有一系列 4 個視圖控制器,每個視圖控制器都從用戶那里獲取一些文本字段,這些文本字段存儲在 NSMutableDictionary 中.

                  I have a sequence of 4 viewControllers inside a NavigationController, each grabs a few textFields of input from the user which are stored in a NSMutableDictionary.

                  每個 VC 的集合在 segue 之前都將自己作為 nextVC 的代表,它還傳遞 NSMutDict.

                  Each of the VC's set's itself up as the delegate of the nextVC before it segues, it also passes the NSMutDict along.

                  這很好用.

                  我不明白的是:

                  假設我已經填寫了 VC1 中的 5 個文本字段.然后我將自己設置為 VC2 的代表,將帶有輸入數據的字典傳遞給 VC2,然后轉到 VC2.在 VC2 中,我填寫了另外 4 個文本字段并將它們添加到字典中.如果我決定需要更改 VC1 中的某些內容,我會點擊后退按鈕并修改數據.但是當我再次前進時,我丟失了我在 VC2 上輸入的內容.

                  Say I have filled in the 5 textFields in VC1. Then I set myself as the delegate of VC2, pass VC2 the dictionary with the input data and segue to VC2. In VC2 I fill in another 4 textFields and add these to the dictionary. If I then decide I need to change something in VC1 I tap the back button and amend the data. But when I go forwards again I lose the stuff I input on VC2.

                  如何將字典與添加的信息一起傳遞回 VC1,以便當它再次轉發到 VC2 時它包含所有內容?

                  How do I pass the dictionary back to VC1 with the added info so that when it gets passed forwards to VC2 again it has everything in it?

                  委托 (VC1) 有一個方法可以用 VC2 中的字典更新其字典.

                  The delegate (VC1) has a method to update its dictionary with the dictionary in VC2.

                  我還自定義了 VC2 中的 backBarButtonItem,方法是在 VC1 的 prepareForSegue: 方法中設置它.

                  I have also customised the backBarButtonItem in VC2 by setting it in the prepareForSegue: method in VC1.

                  我想我已經接近了,但是......

                  I think I'm getting close but...

                  我只能通過在 VC2 中設置 leftBarButtonItem 并使用它而不是默認的后退按鈕來使目標操作起作用.

                  I can only get the target actions to work by setting a leftBarButtonItem in VC2 and using that instead of the default back button.

                  在 VC1 (prepareForSegue:) 中設置后退按鈕似乎不允許設置任何目標或操作.

                  Setting the back button in VC1 (prepareForSegue:) doesn't seem to allow any target or action to be set.

                  我知道我無法在 VC2 中設置后退按鈕,我該怎么辦?我可以使用委托從 VC2 設置后退按鈕的目標和操作嗎?

                  I know I can't set the back button in VC2, so what can I do? Can I set the target and action of the back button from VC2 using the delegate?

                  我認為這可能與 UINavigationBarDelegate 有關,但我不知道該放在哪里.我嘗試在 VC2 中設置它,但它沒有做任何事情.

                  I think it may be something to do with UINavigationBarDelegate but I can't figure out where to put what with that. I tried setting it up in VC2 but it didn't do anything.

                  TIA.

                  以下是相關代碼:

                  協議:

                  #import <Foundation/Foundation.h>
                  
                  @protocol IAXAddNewUserDelegate <NSObject>
                  @required
                  - (void)updateNewUserDataWithData: (NSMutableDictionary *)newData;
                  
                  @end
                  

                  來自 VC1.h:

                  #import "IAXAddNewUserDelegate.h"
                  
                  @interface IAXAddNewUser1 : UITableViewController <UITextFieldDelegate, UIAlertViewDelegate, IAXAddNewUserDelegate>
                  
                  @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
                  @property (strong, nonatomic) User *selectedUser;
                  @property (strong, nonatomic) User *aNewUser;
                  @property BOOL isFirstUser;
                  
                  - (void)updateNewUserDataWithData: (NSMutableDictionary *)newData;
                  
                  @end
                  

                  來自 VC1.m:

                  #pragma mark - Segues
                  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
                  {
                      if ([segue.identifier isEqualToString:@"AddUser2"]) {
                          IAXAddNewUser2 *addUser2VC = segue.destinationViewController;
                          addUser2VC.managedObjectContext = self.managedObjectContext;
                          addUser2VC.progressTotal = self.progressTotal;
                          addUser2VC.isFirstUser = self.isFirstUser;
                          addUser2VC.userData = self.userData;
                          addUser2VC.delegate = self;
                          if (self.selectedUser) {
                              addUser2VC.selectedUser = self.selectedUser;
                          }
                          self.title = @"Step 1";
                          UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" 
                                                                                         style:UIBarButtonItemStyleBordered 
                                                                                        target:self 
                                                                                        action:@selector(passDataBack:)];
                          self.navigationItem.backBarButtonItem = backButton;
                      }
                  }
                  
                  #pragma mark - IAXAddNewUserDelegate Methods
                  - (void)updateNewUserDataWithData: (NSMutableDictionary *)newData
                  {
                      self.userData = newData;
                      NSLog(@"Updated AddUserVC1");
                  }
                  

                  來自 VC2.m

                  -(void)passDataBack:(id)sender
                  {
                      NSLog(@"Sending Data Back to VC1");
                      [self.delegate updateNewUserDataWithData:self.userData];
                      [self.navigationController popViewControllerAnimated:YES];
                  }
                  

                  推薦答案

                  如果您要更新所有其他詞典中的所有詞典,請嘗試使用單例.您可以在此處查看示例:https://stackoverflow.com/a/9690731/542400

                  If you're updating all the dictionaries from all the other dictionaries, try using a singleton. You can see an example here: https://stackoverflow.com/a/9690731/542400

                  另外,這里有一些代碼:

                  Also, here's some code:

                  MainDictionary.h

                  MainDictionary.h

                  @interface MainDictionary : NSObject{
                      NSMutableDictionary *dictionary;
                  }
                  
                  +(MainDictionary *)sharedDictionary;
                  -(NSString *)getStringForKey:(NSString *)string;
                  -(void)setString:(NSString *)string forKey:(NSString *)key;
                  @end
                  

                  MainDictionary.m

                  MainDictionary.m

                  #import "MainDictionary.h"
                  
                  static MainDictionary *sharedDictionary;
                  
                  @implementation MainDictionary
                  
                  -(id)init{
                      self = [super init];
                      dictionary = [[NSMutableDictionary alloc] init];
                      // if you want to add anything preliminary to the dictionary, do it here
                      return self;
                  }
                  
                  +(MainDictionary *)sharedDictionary{
                      static dispatch_once_t onceToken;
                      dispatch_once(&onceToken, ^{
                      sharedDictionary = [[self alloc] init];
                      });
                  return sharedDictionary;
                  }
                  -(NSString *)getStringForKey:(NSString *)string{
                      return [dictionary objectForKey:string];
                  }
                  -(void)setString:(NSString *)string forKey:(NSString *)key{
                      [dictionary setValue:string forKey:key];
                  }
                  @end
                  

                  現在#import MainDictionary.h,只要您想訪問或設置該字典中的值(在本例中,當您的文本字段結束編輯時),只需執行以下操作:

                  Now #import MainDictionary.h, and any time you want to access or set values in that dictionary (in this example, when your textFields end editing), just do this:

                  -(void)textFieldDidEndEditing:(UITextField *)textField{
                      if(textField == textField1){
                          [[MainDictionary sharedDictionary] setString: textField.text forKey:@"textField1"];
                      }
                  }
                  

                  或:

                  -(void)viewWillAppear{
                      textField1.text = [[MainDictionary sharedDictionary] getStringForKey:@"textField1"];
                      [super viewWillAppear:YES];
                  }
                  

                  在每個 VC 中實現這一點,你就可以開始了.

                  Implement this in each VC, and you're good to go.

                  這篇關于試圖在視圖控制器之間傳遞數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))
                  <i id='AmmRo'><tr id='AmmRo'><dt id='AmmRo'><q id='AmmRo'><span id='AmmRo'><b id='AmmRo'><form id='AmmRo'><ins id='AmmRo'></ins><ul id='AmmRo'></ul><sub id='AmmRo'></sub></form><legend id='AmmRo'></legend><bdo id='AmmRo'><pre id='AmmRo'><center id='AmmRo'></center></pre></bdo></b><th id='AmmRo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AmmRo'><tfoot id='AmmRo'></tfoot><dl id='AmmRo'><fieldset id='AmmRo'></fieldset></dl></div>
                • <tfoot id='AmmRo'></tfoot>

                • <legend id='AmmRo'><style id='AmmRo'><dir id='AmmRo'><q id='AmmRo'></q></dir></style></legend>
                    <tbody id='AmmRo'></tbody>
                  • <small id='AmmRo'></small><noframes id='AmmRo'>

                      <bdo id='AmmRo'></bdo><ul id='AmmRo'></ul>
                            主站蜘蛛池模板: 国产精品久久久久久中文字 | 国语对白做受欧美 | www亚洲| 黄色小视频在线播放 | 99小视频 | 欧美xxx视频| 福利影院在线观看 | 午夜在线观看视频 | 免费看黄色aaaaaa 片 | 国产精品一区二区视频 | 狠狠干av | 亚洲精品一区二区在线观看 | 国产精品一区二区在线免费观看 | 国产福利在线 | 99国产精品99久久久久久粉嫩 | 欧美精品亚洲精品 | 国产亚洲视频在线观看 | 五月天婷婷在线观看 | 中文字幕av在线 | 色综合久久88 | 欧美在线日韩 | 欧美在线播放视频 | 成人免费在线播放 | 国产精品成人免费视频 | 久草视频免费 | 精品国产乱码久久久久久88av | 国产精品国产三级国产aⅴ浪潮 | 午夜国产在线观看 | 久久一级片 | 中文字幕在线免费看 | 麻豆黄色片| 国产小视频在线观看 | 欧美色综合天天久久综合精品 | 亚洲日本高清 | 精品久久久久久久久久久久久 | 亚洲一区二区三区四区在线 | 日韩精品久久久久久久酒店 | 日韩中文字幕精品 | 成年人视频在线播放 | 三级视频在线 | 国产精品欧美在线 |