【问题标题】:State of toggle switch in Settings Bundle设置包中切换开关的状态
【发布时间】:2012-11-12 16:06:33
【问题描述】:

我有 UIImageView 在 View 中具有背景图像的作用。我想在此 UIImageView 中加载两个不同的图像,具体取决于在 Settings Bundle 中的切换开关中选择的状态。

最好的方法是什么?

【问题讨论】:

    标签: objective-c xcode ios6 settings.bundle


    【解决方案1】:

    试试这样的:

    NSUserDefaults* settings = [NSUserDefaults standardUserDefaults];
    NSString* imgName = [settings boolForKey:@"toggle_switch"] ? @"switch_on.png" : @"switch_off.png";
    UIImage* img = [UIImage imageNamed:imgName];
    [imageView setImage:img];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2020-06-19
      • 2017-12-29
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      相关资源
      最近更新 更多