久久久久久久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>

        試圖在視圖控制器之間傳遞數(shù)據(jù)

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

          <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>
                  本文介紹了試圖在視圖控制器之間傳遞數(shù)據(jù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送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.

                  這很好用.

                  我不明白的是:

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

                  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,以便當它再次轉(zhuǎn)發(fā)到 VC2 時它包含所有內(nèi)容?

                  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: 方法中設(shè)置它.

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

                  我想我已經(jīng)接近了,但是......

                  I think I'm getting close but...

                  我只能通過在 VC2 中設(shè)置 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:) 中設(shè)置后退按鈕似乎不允許設(shè)置任何目標或操作.

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

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

                  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 有關(guān),但我不知道該放在哪里.我嘗試在 VC2 中設(shè)置它,但它沒有做任何事情.

                  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.

                  以下是相關(guān)代碼:

                  協(xié)議:

                  #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
                  

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

                  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 中實現(xiàn)這一點,你就可以開始了.

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

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

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

                  相關(guān)文檔推薦

                  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(圖標已經(jīng)包含光澤效果)
                  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>
                            主站蜘蛛池模板: 日韩欧美精品在线 | 欧美中文字幕在线观看 | 亚洲欧洲小视频 | 亚洲精品美女视频 | 久久久久国产精品一区 | 中文字幕国产高清 | 久久久久9999 | 欧美日韩一区精品 | 国产精品久久久久久久一区探花 | 国产精品999| 精品日韩一区二区 | 亚洲高清av| 一级片免费网站 | 国产成人精品一区 | 欧美日韩在线一区二区 | 奇色影视| 日本不卡视频在线播放 | 国产一区二区三区 | 亚洲免费精品 | 久久艹免费视频 | 亚洲欧美日韩中文字幕一区二区三区 | 国产wwwcom | 日本久久网 | 日本一区二区视频 | 日韩欧美在线免费 | 成人免费视频网站在线观看 | 天天看片天天干 | 亚洲在线一区 | 精品欧美激情精品一区 | 国产精品91视频 | 天天爱天天操 | 天堂色| 91大神在线资源观看无广告 | 97久久精品午夜一区二区 | 亚洲综合在 | 亚欧精品一区 | 97国产精品 | 免费观看www | 三级免费 | 91短视频网址 | 欧美国产日韩在线 |