0

我有一个选项卡式应用程序。我有 4 个选项卡,在前 2 个选项卡中有选择器视图。如何在第三个选项卡中使用我在第一个和第二个选择器视图中提供的信息?例如:1 个选择器视图:(这是您最喜欢的动物)狗、猫、马。我选狗。现在在第二个选项卡(第二个选择器视图)中:(哪种颜色,无论如何)绿色,蓝色,棕色。我选择棕色。

我希望第一个信息(狗)能够在第三个选项卡中使用。选项:绿色、蓝色和棕色(示例)(无论我选择什么)都是相同的。但是在第三个视图中应该有一只棕色的狗(例如文本“你选择了棕色的狗”)。我希望你明白我的意思... 1. 选择:狗 2. 棕色 = 3rd Tab 棕色狗。这就像一个小数据库......或者我该怎么做?我希望你能帮助我。

谢谢 :-)

4

1 回答 1

0
See the code 

-(IBAction)simple_picker:(id)sender{

    pickerViewPopup = [[UIActionSheet alloc] init];
    const CGFloat toolbarHeight = 44.0f;
    Picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, toolbarHeight, 0, 0)];
    Picker.showsSelectionIndicator = YES;
    Picker.dataSource = self;
    Picker.delegate = self;
    //........
    UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, toolbarHeight)];
    pickerToolbar.barStyle = UIBarStyleBlackOpaque;
    [pickerToolbar sizeToFit];
    NSMutableArray *barItems = [[NSMutableArray alloc] init];

    UIBarButtonItem *cancel= [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(Cancel_picker:)];
    [barItems addObject:cancel];
    UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    [barItems addObject:flexSpace];
    //....
    UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed2:)];
    [barItems addObject:doneBtn];
    [pickerToolbar setItems:barItems animated:YES];
    [pickerViewPopup addSubview:pickerToolbar];

    lbl2.text=[picArray objectAtIndex:0];

    [pickerViewPopup addSubview:Picker];
    [pickerViewPopup showInView:self.view.superview];
    [pickerViewPopup setBounds:CGRectMake(0,0,self.view.frame.size.width, 464)];

}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
    return 1;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
            lbl2.text= [picArray objectAtIndex:row];


}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{

    return [picArray count];

}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{

return [picArray objectAtIndex:row];


}


-(void)btncancelPressed2:(id)sender{
    [pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}

-(void)Cancel_picker:(id)sender{
    [pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}
于 2013-04-29T11:51:11.613 回答