<bdo id='jlovq'></bdo><ul id='jlovq'></ul>
    1. <tfoot id='jlovq'></tfoot>

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

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

      1. 在 pushViewController 之前设置视图控制器属性

        Set view controllers property before pushViewController(在 pushViewController 之前设置视图控制器属性)

        • <legend id='JsAlM'><style id='JsAlM'><dir id='JsAlM'><q id='JsAlM'></q></dir></style></legend>
            <tbody id='JsAlM'></tbody>

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

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

                  本文介绍了在 pushViewController 之前设置视图控制器属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的应用程序中,我为视图添加了标签,将其连接到插座,但当我第一次从另一个视图控制器分配此插座然后调用 pushViewController 以显示它时,什么都没有显示.这是推送下一个显示标签的视图之前的代码:

                  In my app I've added a label to a view, connected it to an outlet but nothing shows up when I first assign this outlet from another view controller and then call pushViewController to display it. Here's the code before pushing next view that display the label:

                  CustomViewController *vc = [[CustomViewController alloc] init];
                  vc.lbl_price.text = self.label_price.text; // lbl_price is defined as a property in CustomViewController and label_price is defined in current view controller
                  [self.navigationController pushViewController:vc];
                  

                  CustomViewController viewDidLoad 方法中我添加了这条指令,看看它是否应该工作

                  In the CustomViewController viewDidLoad method I added this instruction to see if it should work

                  NSLog(@"Price=%@",lbl_price); // it actually prints out what was previously assigned
                  

                  但它没有显示在标签中!

                  But it doesn't show into the label!

                  知道为什么吗?

                  斯蒂芬

                  推荐答案

                  即使创建了视图控制器,它的视图层次也可能不会(因此所有子视图仍然为零),出于优化原因,它可能在您尝试之前不会加载实际访问控制器的视图.您有两种选择来解决您的问题:

                  Even if view controller is created its view hierarchy may not (and so all subviews will still be nil), for optimization reasons it may not be loaded until you try to actually access controller's view. You have two options to solve your problem:

                  1. 将所有值存储在单独的非 UI 变量中,并将它们分配给 UI 组件,其中将出现控制器:

                  1. Store all values in separate non-UI variables and assign them to UI components with controller is going to appear:

                  // Before push controller
                  vc.myPriceText = self.label_price.text;
                  
                  // In controller's viewWillAppear:
                  self.lbl_price.text = self.myPriceText;
                  

                • 调用 [vc view] 以强制控制器加载其视图层次结构:

                • Make [vc view] call to force controller to load its view hierarchy:

                   CustomViewController *vc = [[CustomViewController alloc] init];
                   [vc view];
                   vc.lbl_price.text = self.label_price.text; 
                   [self.navigationController pushViewController:vc];
                  

                • 这篇关于在 pushViewController 之前设置视图控制器属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)

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

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