0

在用户默认值中存储分段控件的 selectedSegment 时出现问题。我正在使用 Segment Selection 绑定并这样做来设置和调用默认值:

[[NSUserDefaults standardUserDefaults] setObject: [modeSegController objectValue] forKey: @"selTag"];

[modeSegController setObjectValue: [[NSUserDefaults standardUserDefaults] objectForKey: @"selTag"]];

不工作。有人可以帮我吗?

-谢谢

保罗。

4

1 回答 1

0

Use [[NSUserDefaults standardUserDefaults] setValue: [ NSNumber numberWithInteger:[modeSegController selectedSegment] ] forKey: @"selTag"]

To show the selected segement use in the UI [modeSegController setSelected:...] the integer

and

[modeSegController setSelectedSegment:[ [NSUserDefaults standardUserDefaults] valueForKey: @"selTag"] integerValue] ]

You needn't use tags to store/restore the selected segment. The segments can be accessed directly.

于 2014-03-24T19:32:35.607 回答