DAY SEVEN – Settings Bundle
今天建立一个 iPhone app,运用 Settings Bundle 设置运行程序
纲要:
-在程序显示前运行代码;
-UILabel的运用;
-把 Settings Bundle 加入程序;
首先运行以安装好的 xCode
选择: File->New Project. 从 "New Project" 窗口
选择 : iPhone OS ->Applications-> View-Based Application
命名 : 这里命名为 "SettingsBundle"
(1)
选择 Settings Bundle; 命名为 Settings.bundle;
(2)
把 PrefernceSpecifiers 前的三角向下,按下,加入:
Item1,
Item2,
Item3,
Item4,
Item5,
Item6,
在 xCode 打开 File -> Save;
(3)
#import <UIKit/UIKit.h>
@interface SettingsBundleViewContro
}
@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 "SettingsBundleViewContro
@implementation SettingsBundleViewContro
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterf
}
- (void)didReceiveMemoryWarning {
}
- (void)dealloc {
}
@end
(5) UIView 界面设置
然后 "Interface Builder"
选择: Tools -> Reveal In Document Window -> View
选择:
在色条内选择 "白色",可以看到背景变为黑色
(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
最后在 xCode 选择 Build -> Build and Go
下载今天教程文件: SettingsBundle.zip