开发者

Keeping User Customized Tab Bar Items

My tab bar app uses the built in "m开发者_高级运维ore" tab where you can customize the tab bar with different items, but When the app quits or shuts down after not being used for a while, the user's customized tab bar changes back to its default settings. I was wondering if there was any way of keeping the customization for ever. I am a novice coder, so any and all code would be greatly appreciated.

Thanks


To save user preferences you can use NSUserDefaults class which is rather simple to use and will do the job you want.

You have to save user preferences when he chooses them:

#define kUserTabBarPreferences @"TabBarUserPreferences"

NSDictionary *tabBarPreferences = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kUserTabBarPreferences];
if (nil == tabBarPreferences) {
// Initialize a new dictionary
}
// Set New preferences in NSDictionary
...
//Save new preferences
[[NSUserDefaults standardUserDefaults] setObject:tabBarPreferences forKey:kUserTabBarPreferences];

When you application is launched, get preferences frome NSUSerDefaults:

NSDictionary *tabBarPreferences = [[NSUserDefaults standardUserDefaults] kUserTabBarPreferences];

And change your application tab bar just as your user prefer it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜