一些小功能实现

一些小功能实现

1. 代码旋转屏幕

 [[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];

2. 默认使用导航控制器包裹的控制器上第一个(从里到外,从上到下的添加顺序)UIScrollView或其子类会向下偏移64个点,也就是说它的bounds.origin.y = -64. 如果你不想让它偏移64,请在viewDidLoad设置

 self.automaticallyAdjustsScrollViewInsets = NO;

3. 跳转到QQ客服聊天界面

注意: 必须使用安装了QQ应用的真机

3.1 对话框的方式打开QQ

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
    NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=123456789&version=1&src_type=web"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    [self.view addSubview:webView];

这里的123456789为咨询客服的QQ号

3.2 打开QQ聊天界面,没有对话框提示

    NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=123456789&version=1&src_type=web"];
     if ([[UIApplication sharedApplication] canOpenURL:url]) {
           [[UIApplication sharedApplication] openURL:url];
    }

适配iOS9,在info.plist中添加跳转的白名单

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>mqq</string>
    </array>

4 修改状态的样式

  1. 设置info.plist文件,不使用基于控制器管理状态栏

    info.plist
  2. 通过Application设置状态栏的样式:
  application.statusBarStyle = .LightContent
原文地址:https://www.cnblogs.com/LiLihongqiang/p/6704632.html