ios - UIPicker single component to display multiple arrays -


The first comment, I hope I am doing this right.

Let me have a UIPicker. I am trying to display 2 column data in a single picker component. The reason I have chosen to do this within 1 component is that I want to scroll arrays together, which I can not get many components to do.

There is a problem, I can not get in this way, or to work as a title, the Forrare and the Viewfire will return only one value (according to C's rules). I tried to make them output arrays and decates, but this has caused data type errors. I can work fine using it 1 component, 1 array with View ForRow, but it allows only the entire area to justify, not parts of the string

The code below works great and returns the correct answer with return label 2; ? And right if label1 change to go back, I get how to display both

  - (UIView *) pickerView: (UIPickerView *) pickerView viewForRow: (NSInteger) line forComponent : (NSInteger) component reusingView: (UIView *) See {UILabel * label1; {Label 1 = [[UILabel alloc] initWithFrame: CGRectMake (10.0F, 150.0F, 130.0F, 60.0F)]; Label1.textAlignment = NSTextAlignmentLeft; Label1.text = [_firstListObjectAntindex: line]; } UILBL * label 2; {Label 2 = [[UILabel alloc] initWithFrame: CGRectMake (100.0f, 10.0f, 175.0f, 100.0f)]; Label2.textAlignment = NSTextAlignmentCenter; Label2.text = [_secondListObjectOntIndex: line]; } Return label 2; }    

code your <> UIPickerView setup for a component.

Now, assuming that the same number of two array _firstList and _secondList objects in them, then you have two options:

  1. Use simple pickerView: titleForRow: forComponent: method to build two single string return values:

      - (NSString *) pickerView: (UIPickerView *) pickerView titleForRow: (NSInteger) line forComponent: (NSInteger) component {return [NSString stringWithFormat: @ "% @ -% @", _firstList [line], _secondList [line]]; }   

    Of course you can format two strings as needed. This is an example

  2. Use pickerView :. ViewForRow: forComponent: reusingView: like you tried but returned the same view connected to that two label.

      - (UIView *) pickerView: (UIPickerView *) pickerView viewForRow: (NSInteger) line forComponent: (NSInteger) component reusingView: (UIView *) view {UILabel * label1; UILBL * label 2; If (see) {label1 = (UILabel *) [View View Tag: 1]; Label1 = (UILabel *) [View View Tag: 2]; } Else {view = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 320, 40)]; UILBL * label 1 = [[UILBL Alloc] InitVithframe: CGRactMake (10.0F, 0.0F, 130.0F, 40.0F)]; Label1.tag = 1; Label1.textAlignment = NSTextAlignmentLeft; UILBL * label2 = [[UILabel alloc] initWithFrame: CGRectMake (100.0f, 0.0f, 175.0f, 40.0f)]; Label2.tag = 2; Label2.textAlignment = NSTextAlignmentCenter; [Adsview view: label 1] View; [Adsview view: label 2] View; } Label1.text = _firstList [line]; Label2.text = _secondList [line]; Return view; }   

    Note how this properly uses the reuse used.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -