《30天精通iPhone手机编程》-Day4-设置文件setting bundle
来源:互联网 发布:windows滚动条平滑滚动 编辑:程序博客网 时间:2024/05/21 17:02
转载自《30天精通iPhone手机编程》原书作者的博客http://blog.sina.com.cn/s/blog_5fae23350100e0qm.html
xCode 打开 File -> New File..
选择 Settings Bundle; 命名为 Settings.bundle;
把 PrefernceSpecifiers 前的三角向下加入:
在 xCode 打开 File -> Save;
(3)
#import <UIKit/UIKit.h>@interface SettingsBundleViewController : UIViewController { IBOutlet UILabel *lblText; IBOutlet UILabel *lblReadOnly; IBOutlet UILabel *lblSlider; IBOutlet UILabel *lblColor; IBOutlet UILabel *lblToogle;}@property (nonatomic, retain) UILabel *lblText;@property (nonatomic, retain) UILabel *lblReadOnly;@property (nonatomic, retain) UILabel *lblSlider;@property (nonatomic, retain) UILabel *lblColor;@property (nonatomic, retain) UILabel *lblToogle;@end
(4)
#import "SettingsBundleViewController.h"@implementation SettingsBundleViewController// The designated initializer. Override to perform setup that is required before the view is loaded.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self;}// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.- (void)viewDidLoad { NSString *textValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"textEntry_key"]; NSString *readOnlyValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"readOnly_key"]; NSString *sliderValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"slider_key"]; NSString *colorValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"colors_key"]; NSString *toogleValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"toogle_key"]; lblText.text = [NSString stringWithFormat:@"Text Value: %@", textValue]; lblReadOnly.text = [NSString stringWithFormat:@"Read Only Value: %@", readOnlyValue]; lblSlider.text = [NSString stringWithFormat:@"Slider Value: %@", sliderValue]; lblColor.text = [NSString stringWithFormat:@"Selected color value: %@", colorValue]; lblToogle.text = [NSString stringWithFormat:@"Toggle Control Value: %@", toogleValue]; }// Override to allow orientations other than the default portrait orientation.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait);}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data}- (void)dealloc { [lblToogle release]; [lblText release]; [lblReadOnly release]; [lblSlider release]; [lblColor release]; [super dealloc];}@end
(5) UIView 界面设置
然后 "Interface Builder"
选择:
(3) 加入
选择: Tools ->
在 Interface Builder
在主视窗口或文件窗口;点击 Label
选择: Tools -> Connection Inspector
移动鼠标在"Touch Up Inside" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner";
放开鼠标选择键出现 "lblText"; 选上它。
其余四个label步骤同上分别选上 “lblReadOnly”,”lblSlider”,”lblToogle”,”lblColor”
选择: File -> Save then close Interface Builde
- 《30天精通iPhone手机编程》-Day4-设置文件setting bundle
- ios7版 30天精通iPhone手机编程 第4天 设置文件Setting Bundle
- 《30天精通iPhone手机编程》-Day17-老虎机
- 《30天精通iPhone手机编程》-Day19-电子琴
- 《30天精通iPhone手机编程》-Day24-烟花
- 《30天精通iPhone手机编程》-Day25-雪花
- 《30天精通iPhone手机编程》-Day26-弹球
- 设置文件setting bundle
- 《30天精通iPhone手机编程》-Day1-macos和iphonesdk简介
- 《30天精通iPhone手机编程》-Day2-hello world
- 《30天精通iPhone手机编程》-Day3-打开网站url连接
- 《30天精通iPhone手机编程》-Day5-文字长度
- 《30天精通iPhone手机编程》-Day6-移动网站导航
- 《30天精通iPhone手机编程》-Day7-长度单位转换器
- 《30天精通iPhone手机编程》-Day8-分歧解决器
- 《30天精通iPhone手机编程》-Day9-密码生成器
- 《30天精通iPhone手机编程》-Day10-迷你秒表
- 《30天精通iPhone手机编程》-Day11-点数器
- 如何通过Makefile编译iphone的openSSL
- asp.net缓存详解
- 算法大全(c,c++)
- Naive Bayes Model
- BGR分解与合并
- 《30天精通iPhone手机编程》-Day4-设置文件setting bundle
- oracle 一个表里有多条记录引用另一个表的主键 并获取此表的最后一条记录
- Linux操作系统多线程同步Mutex详细介绍
- 反射类
- 消息 245,级别 16,状态 1,
- B2B2C
- 观点:如何正确对待设计模式
- strut2 相关
- Linux正确的关机方法