iOS开发中遇到的问题
来源:互联网 发布:mac转码软件 编辑:程序博客网 时间:2024/05/14 15:46
在项目开发中,自己遇到一些问题及解决方法,不断更新中。
(1)UINavigationBar
和UITabBar
上有一条横线,是ShadowImage
,默认是黑色的。在项目开发中,可以改变其图片和颜色。在下图个人热点图中可以看到导航栏下面的黑线。
[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:MyColor]];
(2) statusBar
默认的高度是20.0f,在使用微信或者QQ通话,热点等功能进入后台时,statusBar
的高度会变为40.0f,下方的布局也会发生变化,在此要根据statusBar
的变化调整布局,设置监听监听其变化。
监听对象为UIApplicationDidChangeStatusBarFrameNotification
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];//添加监听[[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil];//移除监听
当前statusBar的高度也是可以获取的:
NSValue *rectValue = [notification.userInfo objectForKey:UIApplicationStatusBarFrameUserInfoKey];CGRect statusRect = [rectValue CGRectValue];CGRect statusFrame = [self.view convertRect:statusRect fromView:[[UIApplication sharedApplication]keyWindow]];CGFloat statusHeight = statusFrame.size.height;
(3)在iPad开发时,使用iOS 9系统会出现tableviewCell
的位置变化,在开发中默认与右侧是15个像素,可是现在明显大的多,这是因为在iOS 9后tableview
的一个属性发生了变化。
需要调整
tableView.cellLayoutMarginsFollowReadableWidth = NO;
补充,因为方法是iOS9之后出现的,因此在调用时需要判断系统是否大于9.0
if([UIDevice currentDevice].systemVersion.floatValue >= 9.0){ tableView.cellLayoutMarginsFollowReadableWidth = NO;}
(4)在做直播功能模块,使用到 弹幕 的功能(弹幕使用第三方库BarrageRenderer
),弹幕为横屏自动开启,竖屏时关闭。在测试用发现弹幕有时开有时关,最终发现在屏幕横放时无法显示。原因是设置方法出现错误。
通过[UIDevice currentDevice].orientation
的状态判断横竖屏会出现错误,因为其枚举类型是UIDeviceOrientation
,在查看其枚举类型时会发现其除了Portrait
LandscapeLeft
LandscapeRight
PortraitUpsideDown
外还有FaceUp
FaceDown
两个状态,忽略对其的设置会产生影响。
UIDeviceOrientation
枚举
typedef NS_ENUM(NSInteger, UIDeviceOrientation) { UIDeviceOrientationUnknown, UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left UIDeviceOrientationFaceUp, // Device oriented flat, face up UIDeviceOrientationFaceDown // Device oriented flat, face down} __TVOS_PROHIBITED;
在对其使用时还可以将其转换成UIInterfaceOrientation
,因为后者只有常见的几种类型。
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
UIInterfaceOrientation
枚举
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown, UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft} __TVOS_PROHIBITED;
另外在横竖屏切换时我们会对屏幕的状态做监听,通常监听的是UIDeviceOrientationDidChangeNotification
,监听得到的结果是UIDeviceOrientation
,也可以监听UIApplicationDidChangeStatusBarFrameNotification
,得到UIInterfaceOrientation
。当然UIApplicationDidChangeStatusBarFrameNotification
也可以监听热点等事件中出现的问题,如问题2.
更多问题后续补充,欢迎探讨指正
- IOS开发中遇到的问题总结
- IOS开发中经常遇到的问题
- 最近iOS开发中遇到的问题
- ios开发中遇到的奇葩问题
- ios生命周期开发中遇到的问题
- ios 开发中遇到的一些问题
- iOS 开发中遇到的小问题
- IOS开发中遇到的各种问题
- iOS开发过程中遇到的问题
- iOS开发中遇到的问题
- iOS开发中遇到的问题整理
- iOS 开发中遇到的问题
- 【iOS开发】ios9开发中遇到的问题
- IOS 开发遇到的问题
- ios开发遇到的问题
- ios开发遇到的问题
- iOS开发遇到的问题
- iOS开发遇到的问题
- java提高篇(八)----详解内部类
- 矩阵分析中的QR分解
- 【Dubbo】利用Jmeter对Dubbo接口进行压力测试
- GCD的背景和使用中的一些问题
- Java Spring IOC用法
- iOS开发中遇到的问题
- 定时任务多线程(结合spring测试)
- JS中如何定义全局变量
- 三星7420 cpu 做的手机源码你们去编译过吗?
- OpenCV 图像数据结构
- 欢迎使用CSDN-markdown编辑器
- SVG动态修改Text的文本
- nologging与append测试
- chromeOS上基于chroot的ubuntu配置笔记(1)