iOS开发常见问题(不断更新)

1.如何从程序退出到桌面

  在单击事件中 exit(0);即可。

2.如何强制横屏

在你需要横屏的控制器里加入如下代码

1 - (BOOL)shouldAutorotate{
2     return NO;
3 }
4 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
5     return UIInterfaceOrientationLandscapeRight;
6 }
7 - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
8     return UIInterfaceOrientationMaskLandscapeRight;
9 }

3.http状态码

302 是请求重定向。

500以上是服务器错误。

400以上是请求链接错误或者找不到服务器。

200以上是正确。

100以上是请求接受成功。

4.全屏手势左滑返回(转☞明神http://www.cnblogs.com/luguojiangshi/)

在自定义的导航控制器里加入如下代码

 1 - (void)viewDidLoad {
 2     [super viewDidLoad];
 3   
 4     id target = self.interactivePopGestureRecognizer.delegate;
 5    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:NSSelectorFromString(@"handleNavigationTransition:")];
 6     pan.delegate = self;
 7     [self.view addGestureRecognizer:pan];
 8     self.interactivePopGestureRecognizer.enabled = NO;
 9 }
10 
11 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
12 {
13     if (self.childViewControllers.count == 1) {
14         return NO;
15     }
16     return YES;
17 }

5.如何让导航Push出视图的坐标系从导航左下角计算

在push出的控制器viewdidload方法里添加下边两行代码即可

1    self.edgesForExtendedLayout = UIRectEdgeNone;
2    self.automaticallyAdjustsScrollViewInsets = NO;

6.使用cocospod时 遇到 Updating local specs repositories 长时间无响应状态解决

 使用新的命令pod install --verbose --no-repo-update

原文地址:https://www.cnblogs.com/yanhuaxuanlan/p/4711254.html