本帖最后由 Simpon 于 2016-10-19 11:36 编辑
1. 代码旋转屏幕 [mw_shl_code=objc,true][[UIDevicecurrentDevice] setValue:@(UIDeviceOrientationLandscapeLeft)forKey:@"orientation"];[/mw_shl_code] 2. 默认使用导航控制器包裹的控制器上第一个(从里到外,从上到下的添加顺序) UIScrollView或其子类会向下偏移64个点,也就是说它的bounds.origin.y = -64. 如果你不想让它偏移64,请在viewDidLoad设置 [mw_shl_code=objc,true]self.automaticallyAdjustsScrollViewInsets =NO;[/mw_shl_code] 3. 跳转到QQ客服聊天界面 注意: 必须使用安装了QQ应用的真机 3.1 对话框的方式打开QQ [mw_shl_code=applescript,true] 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];
[webViewloadRequest:request];
[self.viewaddSubview:webView];[/mw_shl_code] 这里的123456789为咨询客服的QQ号 3.2 打开QQ聊天界面,没有对话框提示 [mw_shl_code=objc,true] 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];
}[/mw_shl_code] 适配iOS9,在info.plist中添加跳转的白名单 [mw_shl_code=applescript,true]<key>LSApplicationQueriesSchemes</key> <array>
<string>mqq</string>
</array>
[/mw_shl_code]文/满山李子(简书作者)
精华推荐:
|