1、设置白色状态栏
2、登陆页面textfield的处理
3、ipad的横竖屏适配
1:mainviewcontroller中
2、单独定义一个协议,选装时调用
3、旁边的tabbar
4、dock中有iconView tabbar bottomMenu
4、为什么我每次获取的屏幕高度都是480宽度都是320
1.不添加相应图片的话,审核过不了.
例如"As of May 1, all new iPhone apps and app updates submitted must support the 4-inch display on iPhone 5. All apps must include a launch image of the appropriate size. Learn more about iPhone 5 support by reviewing the iOS Human Interface Guidelines."
2.只有480的话,屏幕上下自动补黑条.
3.原理:
由于5,5s上市时,需要兼容之前版本的App,同时要减少适配的开发成本.最后就出了唯一的一个判断标准:如果有相应设备尺寸的开机图,系统就当你这个App针对新设备做过适配,否则就按照480x320来算.
后来出了6,6p就沿用了同样的适配规则.
5、autorelease什么时候会自动释放,如何控制不让他释放
在Iphone项目中,大家会看到一个默认的Autorelease pool,程序开始时创建,程序退出时销毁,按照对Autorelease的理解,岂不是所有autorelease pool里的对象在程序退出时才release, 这样跟内存泄露有什么区别?
答案是,对于每一个Runloop, 系统会隐式创建一个Autorelease pool,这样所有的release pool会构成一个象CallStack一样的一个栈式结构,在每一个Runloop结束时,当前栈顶的Autorelease pool会被销毁,这样这个pool里的每个Object会被release。
那什么是一个Runloop呢? 一个UI事件,Timer call, delegate call, 都会是一个新的Runloop。
一般异步执行的代码都需要重新创建autorelease pool,对于在主线程中执行的非UI事件部分的 autorelease 会在什么时候释放呢?
The autoreleased objects will be deallocated when, the closest enclosing autorelease pool on the stack of the thread on which the -autorelease message has been sent, gets drained or released.
6、给UIImageView 设置圆角
originalView.layer.masksToBounds=YES;//方法告诉layer将位于它之下的layer都遮盖住
7、用加载的storyboard创建控制器
8 、通过GestureRecognizer实现点击任意区域隐藏键盘
基本思想如下:
1. 在ViewController载入的时候,将键盘显示和消失的Notification添加到self.view里。
2. 分别在键盘显示和消失时添加和删除TapGestureRecognizer
- (void)viewDidLoad {
[superviewDidLoad];
[selfsetKeyBoardAutoHidden];
}
- (void)setKeyBoardAutoHidden{
NSNotificationCenter*notificationCenter = [NSNotificationCenterdefaultCenter];
//SingleTap Gesture
UITapGestureRecognizer*singleTapGesture = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(backgroundTapDismissKeyboard:)];
NSOperationQueue*mainQueue = [NSOperationQueuemainQueue];
//UIKeyboardWillShowNotification
[notificationCenteraddObserverForName:UIKeyboardWillShowNotificationobject:nilqueue:mainQueueusingBlock:^(NSNotification*note) {
[self.viewaddGestureRecognizer:singleTapGesture];
}];
//UIKeyboardWillHideNotification
[notificationCenteraddObserverForName:UIKeyboardWillHideNotificationobject:nilqueue:mainQueueusingBlock:^(NSNotification*note) {
[self.view addGestureRecognizer:singleTapGesture];
}];
}
- (void)backgroundTapDismissKeyboard:(UIGestureRecognizer*) gestureRecognizer{
//将self.view里所有的subview的first responder 都resign掉
[self.viewendEditing:YES];
}
11,NavigationBar中通过code方式对背景颜色和title字体颜色更改
12、NSCoding解释 initWithCoder: encodeWithCoder
对于轻量级的数据要求,NSCoding因其简单而成为一种比较合适的方式。 NSCoding是一个你需要在数据类上要实现的协议以支持数据类和数据流间的编码和解码。数据流可以持久化到硬盘。
是类对象本身数据的写入到本地文件。
我 们需要实现两个方法: encodeWithCoder和initWithEncoder。encodeWithCoder就是编码,initWithCoder就是解码。 encodeWithCoder方法传入的是一个NSCoder对象,实现的时候我们就可以调用encodeObject、encodeFloat、 encodeInt等各种方法并通过指定键值进行编码。
13、数组里面存储CGRect
存:[self.bottomLineFrameArr addObject:[NSValue valueWithCGRect:bottomRect]];
取:self.bottomLineView.frame = [self.bottomLineFramesArrayM[0] CGRectValue];
14、野指针的错误
野指针的错误unrecognized selector sent to instance
15、id类型与instancetype类型
instancetype 与 id 不一样, instancetype 只能在方法声明中作为返回类型使用。
使用 instancetype ,编译器将正确的推断出 +personWithName: 是 Person 的一个实例。
16、类方法和实例方法
实例方法是— 类开头是+
实例方法是建立实例才有的方法,实例方法是用实例对象访问
类方法是直接可以使用类引用,不需要实例化就可以使用的方法,一般在项目中类方法都是设置为工具类使用的
类方法的对象是类而不是实例,通常创建对象或者工具类。
在实例方法里,根据继承原理发送消息给self和super其实都是发送给self
在类方法里面self是其他的类的类方法,在类方法中给self发送消息只能发类方法self是类super也是
什么时候用类方法,要创建一个实例时候获取一个共享实例,或者获取关于类的一些共有信息
17.tableview的第一个headerView设置标题不走
因为tableviewheader的高度高度没有设置
18. TableView如何刷新指定的cell 或section
//一个section刷新
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
[tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
//一个cell刷新
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
19.创建分类的方法