设置文件setting bundle

xCode 打开 File -> New File.. 

选择 Settings Bundle; 命名为 Settings.bundle;

把 PrefernceSpecifiers 前的三角向下加入:


 xCode 打开 File -> Save

 

(3)  xCode 打开 SettingBundleViewController.h 文件,加入代码

[plain]  view plain copy
  1. #import <UIKit/UIKit.h>  
  2.   
  3. @interface SettingsBundleViewController : UIViewController {  
  4.       
  5.     IBOutlet UILabel *lblText;  
  6.     IBOutlet UILabel *lblReadOnly;  
  7.     IBOutlet UILabel *lblSlider;  
  8.     IBOutlet UILabel *lblColor;  
  9.     IBOutlet UILabel *lblToogle;  
  10. }  
  11.   
  12. @property (nonatomic, retain) UILabel *lblText;  
  13. @property (nonatomic, retain) UILabel *lblReadOnly;  
  14. @property (nonatomic, retain) UILabel *lblSlider;  
  15. @property (nonatomic, retain) UILabel *lblColor;  
  16. @property (nonatomic, retain) UILabel *lblToogle;  
  17.   
  18. @end  


(4)  xCode打开 SettingsBundleViewController.m 文件,加入下面代码

[plain]  view plain copy
  1. #import "SettingsBundleViewController.h"  
  2.   
  3. @implementation SettingsBundleViewController  
  4.   
  5. // The designated initializer. Override to perform setup that is required before the view is loaded.  
  6. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {  
  7.     if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {  
  8.         // Custom initialization  
  9.     }  
  10.     return self;  
  11. }  
  12. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.  
  13. - (void)viewDidLoad {  
  14.     NSString *textValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"textEntry_key"];  
  15.     NSString *readOnlyValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"readOnly_key"];  
  16.     NSString *sliderValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"slider_key"];  
  17.     NSString *colorValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"colors_key"];  
  18.     NSString *toogleValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"toogle_key"];  
  19.      
  20.     lblText.text = [NSString stringWithFormat:@"Text Value: %@", textValue];  
  21.     lblReadOnly.text = [NSString stringWithFormat:@"Read Only Value: %@", readOnlyValue];  
  22.     lblSlider.text = [NSString stringWithFormat:@"Slider Value: %@", sliderValue];  
  23.     lblColor.text = [NSString stringWithFormat:@"Selected color value: %@", colorValue];  
  24.     lblToogle.text = [NSString stringWithFormat:@"Toggle Control Value: %@", toogleValue];  
  25.      
  26. }  
  27. // Override to allow orientations other than the default portrait orientation.  
  28. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  
  29.     // Return YES for supported orientations  
  30.     return (interfaceOrientation == UIInterfaceOrientationPortrait);  
  31. }  
  32.   
  33. - (void)didReceiveMemoryWarning {  
  34.     [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview  
  35.     // Release anything that's not essential, such as cached data  
  36. }  
  37.   
  38. - (void)dealloc {  
  39.     [lblToogle release];  
  40.     [lblText release];  
  41.     [lblReadOnly release];  
  42.     [lblSlider release];  
  43.     [lblColor release];  
  44.     [super dealloc];  
  45. }  
  46. @end  


(5) UIView 界面设置

双击文件: "SettingsBundleViewController.xib" 

然后 "Interface Builder"  会自动打开,在这里我们可以编辑改变界面
 
选择: Tools -> Reveal In Document Window -> View

选择 Tools -> Attributes Inspector

在色条内选择 "",可以看到背景变为黑色实例iPhone编程入门教程-第七天

(3)
 加入 五个 Label

选择: Tools -> Label  Library显示菜单中拖拉一个 Label  Main View
 Interface Builder

在主视窗口或文件窗口;点击 Label

选择: Tools -> Connection Inspector

移动鼠标在"Touch Up Inside" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner";
放开鼠标选择键出现 "lblText"; 选上它。

其余四个label步骤同上分别选上 “lblReadOnly”,”lblSlider”,”lblToogle”,”lblColor”

选择: File -> Save then close Interface Builde 

最后在 xCode 选择 Build -> Build and Go

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值