0

我正在创建一个客户。选择一个帐户并且该帐户通过(通过segue)。想知道它是如何做到的。obs ** 数据传递是用户选择的选择器的数组(帐户)。

这将返回选择器视图:

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

必须将用户选择的选项(数组)传递给另一个视图以用作帐户(Twitter)

我设法用 TableView 做了一次(但我认为界面很糟糕)并决定制作pickerview。问题仅在于传递此数据(如下),不等于 tableview

4

2 回答 2

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.

于 2014-06-10T19:50:02.347 回答
0

我希望我能理解你,你的描述/拼写有点模糊。

您需要实现此委托方法:

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

我不建议在选择器视图上选择时切换视图,如果您使用按钮执行 segue 会更好。您可以将选择保存在私有属性中,并使用它prepareForSegue:来将其传递给另一个视图控制器。

于 2013-01-04T15:28:54.207 回答