1. 判断是否是iPad
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
2. iOS版本判断
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_5_1
[navigationController.navigationBar addSubview:imageView];
#else
[navigationController.navigationBar insertSubview:imageView atIndex:0];
#endif
3. 自定log 调试用
#define showLogInfo 1
#if showLogInfo
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...)
#endif
4. 各目录路径获取
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
2. iOS版本判断
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_5_1
[navigationController.navigationBar addSubview:imageView];
#else
[navigationController.navigationBar insertSubview:imageView atIndex:0];
#endif
3. 自定log 调试用
#define showLogInfo 1
#if showLogInfo
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...)
#endif
4. 各目录路径获取

本文介绍了在iOS开发中如何使用宏进行条件判断,并详细讲解了获取沙盒主目录、Documents目录、Caches目录和tmp目录路径的方法,包括NSHomeDirectory()、NSSearchPathForDirectoriesInDomains函数的应用。

1万+

被折叠的 条评论
为什么被折叠?



