ios 开发小记 (二)
一些开发中的常见问题:
1、interface builder 使用
identity inspector 的key path 可以用来做圆角按钮和边框,不用在代码里面写。
layer.cornerRadius number 圆角按钮
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer.timeoutInterval = 10;
UINavigationController 更灵活,可以push,然后pop。
[self performSelectorOnMainThread:@selector(updateUI:) withObject:image waitUntilDone:YES];
8、UI自动布局
layout有三种方式:Manual layout,Autoresizing,Autolayout。我们常用的可能就后面两种。
假设v1是一个不使用autolayout的view,而v2是一个使用autolayout的view,但v1成为v2的subview时,
v2需要四条隐含的constraint来确定v1的位置,这些约束都是从v1的frame转化而来:
This conversion is performed only if the view in question has its translates-
AutoresizingMaskIntoConstraints property set to YES. That is, in fact, the default if
the view came into existence either in code or by instantiation from a nib where “Use
Auto Layout” is not checked. The assumption is that if a view came into existence in
either of those ways, you want its frame and autoresizingMask to act as its constraints
self.navigationController popToRootViewControllerAnimated:YES]
UIViewController *prevVC = [self.navigationController.viewControllers objectAtIndex:<n>];
[self.navigationController popToViewController:prevVC animated:YES];
[self.navigationController popViewControllerAnimated:YES];
(那么可以通过单例、代理模式、notify等各种形式传递)
10、UIViewoController的关系
willMoveToParentViewController:
method of the child view controller before calling the removeFromParentViewController
method...Thus, as discussed in Adding and Removing a Child section of the View Controller Programming Guide, when removing a child, we should:
[childVC willMoveToParentViewController:nil];
[childVC.view removeFromSuperview];