<tfoot id='U7aFv'></tfoot>

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

  1. <i id='U7aFv'><tr id='U7aFv'><dt id='U7aFv'><q id='U7aFv'><span id='U7aFv'><b id='U7aFv'><form id='U7aFv'><ins id='U7aFv'></ins><ul id='U7aFv'></ul><sub id='U7aFv'></sub></form><legend id='U7aFv'></legend><bdo id='U7aFv'><pre id='U7aFv'><center id='U7aFv'></center></pre></bdo></b><th id='U7aFv'></th></span></q></dt></tr></i><div id='U7aFv'><tfoot id='U7aFv'></tfoot><dl id='U7aFv'><fieldset id='U7aFv'></fieldset></dl></div>

        <bdo id='U7aFv'></bdo><ul id='U7aFv'></ul>
      <legend id='U7aFv'><style id='U7aFv'><dir id='U7aFv'><q id='U7aFv'></q></dir></style></legend>
    1. 在导航堆栈中将模型对象从一个视图控制器传递到另一个视图控制器

      时间:2023-06-10
          <tfoot id='N2i1d'></tfoot>

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

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

                <bdo id='N2i1d'></bdo><ul id='N2i1d'></ul>
                  <tbody id='N2i1d'></tbody>
              • <legend id='N2i1d'><style id='N2i1d'><dir id='N2i1d'><q id='N2i1d'></q></dir></style></legend>
              • 本文介绍了在导航堆栈中将模型对象从一个视图控制器传递到另一个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两个 UITableViewController.一个显示名称列表,点击任何单元格将推送第二个 TableViewController,使用户能够在 UITextField 中编辑名称.

                I have two UITableViewControllers. One displays a list of names and on tapping any cell will push the second TableViewController which enables the user to edit the name in a UITextField.

                现在我可以将名称字符串从第一个 TableViewController 传递到第二个.(我通过在第二个 TableViewController 中创建一个属性来做到这一点,我在推送第二个 TableViewController 之前设置该属性)但是我如何将编辑后的名称字符串从第二个传递到第一个(这样我就可以更新第一个表用编辑过的名字)?

                Now I am able to pass the name string from the first TableViewController to the second. (I'm doing this by creating a property in the second TableViewController which I'm setting just before pushing the second TableViewController) But how do I pass the edited name string from the second to the first (so that I can update the first table with the edited name)?

                推荐答案

                在第一个控制器中创建一个可变数组属性,并将该数组和一个索引传递给第二个控制器.

                Create a mutable array property in the first controller, and pass that array and an index to the second controller.

                FirstController.h

                FirstController.h

                   @property (nonatomic,retain)     NSMutableArray *myStrings;
                

                FirstController.m

                FirstController.m

                   @synthesize myStrings;
                
                   init {
                         self.myStrings = [NSMutableArray arrayWithCapacity:8];
                   }
                
                
                   didSelectRowAtIndexPath {
                
                     SecondVC *vc = [[SecondVC new];
                     [self.theStrings addObject:@"Original String"]; // or replaceAtIndex: indexPath.row
                     vc.theStrings = self.myStrings;
                     vc.theIndex   = indexPath.row;
                     //push detail vc.
                   }
                

                SecondController.h

                SecondController.h

                  @property (nonatomic, retain) NSMutableArray *theStrings;
                  @property (nonatomic        ) int             theIndex;
                

                SecondController.m

                SecondController.m

                  @synthesize theStrings;
                  @synthesize theIndex;
                
                  doneEditingMethod {
                       [self.theStrings replaceObjectAtIndex: self.theIndex withObject: myNewString];
                   }
                

                这篇关于在导航堆栈中将模型对象从一个视图控制器传递到另一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将文本导入每个 NavigationController 视图的最佳方法 下一篇:更改所有导航栏中的标题文本颜色和字体

                相关文章

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

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

                  1. <legend id='KhqRS'><style id='KhqRS'><dir id='KhqRS'><q id='KhqRS'></q></dir></style></legend>
                    • <bdo id='KhqRS'></bdo><ul id='KhqRS'></ul>
                  2. <tfoot id='KhqRS'></tfoot>