gpt4 book ai didi

iphone - 显示 UIPickerview 选择的值

转载 作者:行者123 更新时间:2023-12-01 17:55:35 25 4
gpt4 key购买 nike

我有一个 UIPickerView显示项目数组。当我选择一个项目时,它可以传递给我所有的 View Controller 。现在我的问题是在移动到不同的 view controllers 之后并返回到UIPIckerView它显示了第一个数组项,而不是我选择的项。如何查看所选项目?

//in viewDidLoad()
itemsArray = [[NSArray alloc] initWithObjects:@"5", @"10", @"20", @"30", @"50",@"100", nil];

// if i select 20 and moved to other pages of my controllers and
// return to the UIPickerView i can see the 5 as selected not the 20

有什么建议么?

最佳答案

嗨,使用 NSUserDefaults 来保存当前选定的值,使用 ,

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSNumber numberWithInt:albumCount] forKey:@"AlbumCount"];
[defaults synchronize];

为了取回清酒,
albumCount = [defaults integerForKey:@"AlbumCount"];

关于iphone - 显示 UIPickerview 选择的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18337599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com