随笔分类 - iOS
摘要:效果:分别拖动下方和上方滚动视图用数组把所有的UIScrollView对象储存起来。 1 #import "ViewController.h" 2 3 @interface ViewController () <UIScrollViewDelegate> 4 5 @end 6 7 @implementation ViewController 8 9 @synthesize scrollViews = _scrollViews;10 11 - (void)viewDidLoad12 {13 [super viewDidLoad];14 15 UIImageView
阅读全文
摘要:在上一篇博文《在滚动视图里添加图像视图,在图像视图里添加按钮控件》的基础上做了小小的改动。》》点击button1》》》》点击button2》》需要改写两个地方:@synthesize scrollView = _scrollView;- (void)viewDidLoad{ [super viewDidLoad]; // 配置 UIImageView 对象 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]]; imgView.userIn...
阅读全文
摘要:》》点击按钮“Button”》》》》绿底的是一张图片(1.png),截自苹果文档。第一个视图对应VC1:VC1 1 @synthesize scrollView = _scrollView; 2 3 - (void)viewDidLoad 4 { 5 [super viewDidLoad]; 6 7 // 配置 UIImageView 对象 8 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]]; 9 imgView.user...
阅读全文
摘要:首先保证:1 self.tableView.allowsSelection = YES; // 默认是 YES2 self.tableView.allowsSelectionDuringEditing = YES;UITableView中的声明:1 @property(nonatomic) BOOL allowsSelection __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // default is YES. Controls whether rows can be selected when not in editing mode2..
阅读全文
摘要:1 - (void)viewDidLoad 2 { 3 [super viewDidLoad]; 4 5 self.editButtonItem.possibleTitles = [NSSet setWithObjects:@"编辑", @"完成", nil]; 6 self.editButtonItem.title = @"编辑"; 7 self.navigationItem.leftBarButtonItem = self.editButtonItem; 8 } 9 10 - (void)setEditing:(BOOL)edit
阅读全文
摘要:在调试应用的时候,可以查看数据库里的数据。以下内容摘自《Pro.Core.Data.for.iOS. Second.Edition》。1、定位到模拟器的目录cd ~/Library/Application\ Support/iPhone\ Simulator2、查找文件名包含OrgChart.sqlite的文件,并打印路径find . -name "OrgChart.sqlite" –print输出:./5.0/Applications/E8654A34-8EC4-4EAF-B531-00A032DD5977/Documents/OrgChart.sqlite3、进入SQL
阅读全文
摘要:1、reason: '[<CTXCourseDetailViewController 0x6db4010> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableview.'原因:删除了原来在Storyboard中的 Table View 在CTXCourseDetailViewController 中的Outlet ‘tableview’。2、在Storyboard中,在View Controller 中添加 Table View*** T
阅读全文
摘要:最新修改(2012-11-17):两个segue都为Push,指向同一个View Controller,通过变量指定是新增一个对象还是修改原来对象。============================================================================只是为了试验下,所以代码和界面做地比较搓。通过点击1,进行一个Model 的 Segue,显示2;通过点击2的返回按钮,进行一个Push 的Segue,显示3。如图1图1类似于通讯录新增联系人。通过点击2-1中的+,显示2-2新增联系人并进行编辑;通过点击2-2的Done,显示2-3进行编辑或者返回
阅读全文
摘要:我还是菜鸟,写下的记录不一定完全正确。多找资料,多google吧。Xcode 4.3.21、添加Frameworks,或者看图2、找不到设置,可以在搜索栏里搜索关键字。比如设置自动引用计数(ARC),在右上方输入关键字“ARC”。3、添加输出口(Outlets)或响应事件的方法(Actions),可以直接控件拖到对应的视图控制器实例类文件中。4、在Storyboard中能否使用xib文件?A:见6。5、用Storyboard建的视图能否用在iOS4或更早的版本中?A:storyboards will run only on devices sporting iOS 5 and above.6、
阅读全文
摘要:在persistentStoreCoordinator 1 - (NSPersistentStoreCoordinator *)persistentStoreCoordinator 2 { 3 if (__persistentStoreCoordinator != nil) { 4 return __persistentStoreCoordinator; 5 } 6 7 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Lo...
阅读全文
摘要:Q:@synthesize propertyname = _propertyname; 为什么要使用 _propertyname?什么时候用self.propertyname ,什么时候用_propertyname?A:当:@synthesize propertyname = _propertyname;An initialization method is one of two places in which you should not use accessor methods to access properties (the other place is in a dealloc me
阅读全文
摘要:http://www.opensource.apple.com/iOS Developer LibraryXcode 4 User GuideThe Objective-C Programming LanguageiOS Human Interface GuidelinesTransitioning to ARC Release NotesAdvanced Memory Management Programming GuideUICatalogProperty List Programming GuidePreferences and Settings Programming GuideThr
阅读全文
摘要:1 2012-07-31 00:52:35.709 apress-16-3[2345:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x6a71920> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key latitudeLabel.'.xib 中的 Labe 控件链接到 .h
阅读全文
摘要:In Xcode 4.3.2,Right click the Project Name in the Project Navigator, and choose "Show in Finder";In Finder, right click the setting.bundle and choose "Show Package Contents";Copy the new .plist to setting.bundle;Back to XCode, open the "setting.bundle", wilfully add on
阅读全文
摘要:建立Empty Application,新建Storyboard并添加View Controller 控件后运行为空白,并报错控制台显示:2012-07-18 15:21:57.338 apress-8[664:f803] Application windows are expected to have a root view controller at the end of application launch通过和Single View Application模版对比发现:需要至少修改两个地方:1、AppDelegate.m 1 - (BOOL)application:(UIApplica
阅读全文
摘要:用Storyboard做的。做点记录总的效果:总的结构:视图结构:新建一个Tabbed ApplicationPS:我直接建Single View Application,然后删除里面的ViewController类文件和Storyboard中默认的控制器视图,自己添加Tab Bar Controller 控件新建一个UITabBarController类的文件(.h,.m);PS:在本次学习内容中,对UITabBarController类文件没有修改。Tab Bar Controller控件关联到UITabBarController实例。分别添加标签栏中标签所对应的控制器控件(本次用到5个V
阅读全文
摘要:SwitchViewController 负责在按下Switch Views 时切换 BlueViewController 和 YellowViewController。控制器类 和 对应的 .xib文件 都是单独创建。手动组建效果图:1、新建 Empty Application 。不选 “Use Core Data”2、新建 SwitchViewController 类和 SwitchViewController.xib BlueViewController 类和BlueView.xib YellowViewController 类和 YellowView.xib3、编写Swit...
阅读全文
摘要:Portrait:主视图为竖放;Landscape:主视图为横放。Interface Builder,以下简称IB(我习惯用StoryBoard来做的,一下简称SB)。设置视图横放(在IB中),选择要横放的视图,在右边的Orientation中选择Landscape:做“切换视图”这个内容,在SB中没思绪,先找着书在IB中做了一遍,在回到SB中做了一遍。在SB中:需要在View Control中分别移进移出两个View来做控件布局,感觉略麻烦。效果图:对与属性设置strong或weak还有点疑惑?两个视图的属性射程weak,则运行后是黑屏:
阅读全文
摘要:1、完成输入后关闭键盘:选中Text Field控件,设置Return Key为Done:为控件添加事件:点击Done隐藏键盘:2、通过触摸背景关闭键盘:更改View指向的对象类,原先为UIView,通过右边改成UIControl,注意左边红框中原先名为View:选中当前的名为Control的图标:为它添加事件,注意箭头指出的是与方法建立联系的UIContril对象:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~点击背景即可隐藏键盘
阅读全文

浙公网安备 33010602011771号