久久久久久久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>
                            主站蜘蛛池模板: 国产成人高清成人av片在线看 | 免费看国产片在线观看 | 国产精品久久久久久久久久久久午夜片 | 91精品国产乱码久久久久久久久 | 午夜精品久久久久久久久久久久久 | 欧美一级一区 | 91视频大全| 亚洲免费一 | 亚洲一区二区三区视频 | 亚洲一页 | 国产高潮av| 国产免费一区二区三区最新6 | 亚洲一区二区三区四区五区中文 | 国产成人精品一区二区三区四区 | 91精品久久久 | 日韩精品不卡 | 亚洲日本欧美 | 日韩av在线中文字幕 | 91在线影院 | 婷婷成人在线 | 欧美黑人狂野猛交老妇 | 91麻豆精品国产91久久久更新资源速度超快 | 欧美视频免费在线 | 青草青草久热精品视频在线观看 | 日韩精品一区二区三区中文字幕 | 欧美日韩三区 | 日韩一区二区三区在线 | 毛片区 | 成人一区av| 一区二区三区高清 | 日韩免费成人av | 美女视频一区二区三区 | 亚洲综合大片69999 | 日本不卡一区 | 羞羞视频在线免费 | 国产黄色小视频在线观看 | 欧美嘿咻 | 最新一级毛片 | 性一交一乱一伦视频免费观看 | 黄色免费网站在线看 | 欧美一区二区三区在线观看 |