<tfoot id='gradV'></tfoot>

    <bdo id='gradV'></bdo><ul id='gradV'></ul>

  • <small id='gradV'></small><noframes id='gradV'>

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

      1. 如何将多个组件添加到 PickerView?

        How do I add multiple components to a PickerView?(如何将多个组件添加到 PickerView?)
        <tfoot id='VE8Qf'></tfoot>
          • <bdo id='VE8Qf'></bdo><ul id='VE8Qf'></ul>

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

              • <small id='VE8Qf'></small><noframes id='VE8Qf'>

                  <tbody id='VE8Qf'></tbody>
              • <i id='VE8Qf'><tr id='VE8Qf'><dt id='VE8Qf'><q id='VE8Qf'><span id='VE8Qf'><b id='VE8Qf'><form id='VE8Qf'><ins id='VE8Qf'></ins><ul id='VE8Qf'></ul><sub id='VE8Qf'></sub></form><legend id='VE8Qf'></legend><bdo id='VE8Qf'><pre id='VE8Qf'><center id='VE8Qf'></center></pre></bdo></b><th id='VE8Qf'></th></span></q></dt></tr></i><div id='VE8Qf'><tfoot id='VE8Qf'></tfoot><dl id='VE8Qf'><fieldset id='VE8Qf'></fieldset></dl></div>
                  本文介绍了如何将多个组件添加到 PickerView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这可能是一个简单的问题,但是如何将多个组件添加到 UIPickerView?我使用 NSMutableArray 填充一个组件,但我不知道如何填充其他组件.选择一行时,我还需要更改标签的值.提前致谢基兰

                  It may be a simple question but how do I add multiple components to a UIPickerView? I use NSMutableArray to populate one component but I dont know how to populate the others. I also need to change the value of a label when a row is selected. Thanks in advance Kieran

                  推荐答案

                  我认为你是初学者.以下是如何实现 nacho 正确指出的方法:

                  I take it that you are a beginner. Here's how to implement the methods nacho has rightly pointed out:

                  - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
                      // return the number of components required
                      return 2;
                  }
                  

                  您可以使用其他 NSMutableArray 来填充组件.假设您有 2 个组件,每个组件使用不同的 NSMutableArrayarray1array2:

                  You can use other NSMutableArray's to populate the components. Assuming that you have 2 components, each using different NSMutableArray i.e. array1 and array2:

                  // Return row count for each of the components
                  - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
                      if (component == 0) {
                          return [array1 count];
                      }
                      else {
                          return [array2 count];
                      }
                  }
                  
                  // Populate the rows of the Picker
                  - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
                  
                      // Component 0 should load the array1 values, Component 1 will have the array2 values
                      if (component == 0) {
                          return [array1 objectAtIndex:row];
                      }
                      else if (component == 1) {
                          return [array2 objectAtIndex:row];
                      }
                      return nil;
                  }
                  

                  使用此代码更改 label 的文本,例如在 PickerView 中选择值时说 selectedValue:

                  Use this code to change the text of a label, say selectedValue when a value is selected in the PickerView:

                  - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
                      selectedValue.text = [NSString stringWithFormat: @"%@, %@", [array1 objectAtIndex:[myPicker selectedRowInComponent:0]],[array2 objectAtIndex:[myPicker selectedRowInComponent:1]]];
                  }
                  

                  ...你很高兴:)

                  您可能还想查看 http://joshhighland.com/blog/2009/09/17/uipickerview-spinning-multiple-components/ 获取有关 pickerView 编程的宝贵提示.

                  You might also want to see http://joshhighland.com/blog/2009/09/17/uipickerview-spinning-multiple-components/ for valuable tips on pickerView programming.

                  这篇关于如何将多个组件添加到 PickerView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                  When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                  Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                  Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)

                      <tbody id='iyb5d'></tbody>

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

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

                    • <legend id='iyb5d'><style id='iyb5d'><dir id='iyb5d'><q id='iyb5d'></q></dir></style></legend>

                      <tfoot id='iyb5d'></tfoot>
                          <bdo id='iyb5d'></bdo><ul id='iyb5d'></ul>