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

        <tfoot id='K4Q83'></tfoot>

        <legend id='K4Q83'><style id='K4Q83'><dir id='K4Q83'><q id='K4Q83'></q></dir></style></legend>

        从 UIViewController 返回 NSString

        时间:2023-10-04

          1. <small id='sCEEd'></small><noframes id='sCEEd'>

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

              <tbody id='sCEEd'></tbody>

              • <bdo id='sCEEd'></bdo><ul id='sCEEd'></ul>

                <legend id='sCEEd'><style id='sCEEd'><dir id='sCEEd'><q id='sCEEd'></q></dir></style></legend><tfoot id='sCEEd'></tfoot>
                  本文介绍了从 UIViewController 返回 NSString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想从一个名为 InputUIViewController 的 UIViewController 返回一个 NSString * 到之前的 UIViewController,称为 CallerUIViewController,它启动了 InputUIViewController.我想在 InputUIViewController 调用之前或调用时这样做:

                  I want to return a NSString * from a UIViewController, called InputUIViewController, to the previous UIViewController, called CallerUIViewController, which started InputUIViewController. I want to do it just before or when InputUIViewController calls:

                  [self dismissModelViewControllerAnimated:YES];

                  有标准的方法吗?

                  推荐答案

                  执行此操作的标准方法是使用委托.

                  The standard way to do this would be to use a delegate.

                  在您的 InputViewController 中添加一个新的委托协议,以及您的委托的一个属性.

                  In your InputViewController add a new delegate protocal, and a property for your delegate.

                  然后在您的 CallerUIViewController 中实现委托.然后就在您关闭模态视图控制器之前,您可以回调您的委托.

                  Then in your CallerUIViewController implement the delegate. Then just before your dismiss the modal view controller you can call back to your delegate.

                  所以你的 InputViewController 可能看起来像这样:

                  So your InputViewController might look like this:

                  @protocol InputViewControllerDelegate;
                  
                  @interface InputViewControllerDelegate : UIViewController {
                  }
                  
                  @property (nonatomic, assign) id <InputViewControllerDelegate> delegate;
                  
                  @end
                  
                  
                  @protocol InputViewControllerDelegate
                  - (void)didFinishWithInputView:(NSString *)stringValue;
                  @end
                  

                  关闭模态视图的方法如下所示:

                  The method that dismisses the modal view would look something like this:

                  -(void)dismissSelf
                  {
                     [self.delegate didFinishWithInputView:@"MY STRING VALUE"];
                     [self dismissModalViewControllerAnimated:YES];
                  }
                  

                  然后在 CallerUIViewController 中实现 InputViewControllerDelegate 和 didFinishWithInputView 方法.

                  Then in your CallerUIViewController you would implement the InputViewControllerDelegate and the didFinishWithInputView method.

                  CallerUIViewController 标头类似于:

                  The CallerUIViewController header would look something like:

                  @interface CallerUIViewController : UIViewController <InputViewControllerDelegate> {
                  }
                  

                  您的 didFinishWithInputView 方法将被实现为:

                  and your didFinishWithInputView method would be implemented something like:

                  - (void)didFinishWithInputView:(NSString *)stringValue
                  {
                      // This method will be called by the InputViewController just before it is dismissed
                  }
                  

                  就在您呈现 InputViewController 之前,您需要将委托设置为 self.

                  Just before your present the InputViewController you would set the delegate to self.

                  -(void)showInputViewController
                  {
                     InputViewController *inputVC = [[InputViewController alloc] init];
                     inputVC.delegate = self;
                  
                     [self presentModalViewController:inputVC animated:YES];
                  
                     [inputVC release];
                  }
                  

                  这篇关于从 UIViewController 返回 NSString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:GPS isProviderEnabled 总是返回 false 下一篇:Android:从软键盘中删除 Enter 键

                  相关文章

                  <tfoot id='N8dAd'></tfoot>
                  <legend id='N8dAd'><style id='N8dAd'><dir id='N8dAd'><q id='N8dAd'></q></dir></style></legend>

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

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

                      • <bdo id='N8dAd'></bdo><ul id='N8dAd'></ul>