0

I am creating a client. selects an account and the account passes (through segue). wanted to know how it does it. obs ** data passing is an array (of account) of a picker selected by the User.

This returns the pickerview:

-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 
  ACAccount *acct = [arrayOfAccounts objectAtIndex:row]; 
  return [acct username];
}

have to pass the option (array) selected by the User to another view to use as Account (Twitter)

I managed to do it once with TableView (but I thought the horrible interface) and decided to make pickerview. the problem only in passing this data (below), is not equal to tableview

Lcstest Test
  • 113
  • 1
  • 2
  • 9

2 Answers2

0

I hope i get you right, your description/spelling is a bit vague.

You need to implement this delegate method:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

I wouldnt recommend to switch the view upon selection on the picker view, its better if you use a button to execute the segue. You can save the selection in a private property and use it in prepareForSegue: to pass it to the other view controller.

artey
  • 1,243
  • 7
  • 10
0

Are you using a Segue to pass the data to the next view? i think that would be the best way to do that. When passing the data from the pickerview, in your segue you can do this

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"moreinfosegue"])
    {
        // Get reference to the destination view controller
        NextViewController *nextViewC = [segue destinationViewController];
        // Pass any objects to the view controller here, like...
        ACAccount *acct = [self.arrayOfAccounts objectAtIndex:[_yourPickerView selectedRowInComponent:0]];

        [nextViewC  setACAccountValueInOtherView:acct];

    }
}

Just remember that the selectedRowInComponent is set to whatever component you are taking it from the UIPickerView.

I hope this helps.

vnchopra
  • 149
  • 10