一行代码判断运行应用的机器是IOS4还是IOS3
[[UIDevice currentDevice] systemVersion]
生成随机guid串的代码
代码由 CocoaChina 会员“garnett2183”分享
- + (NSString*) stringWithUUID {
- CFUUIDRef uuidObj = CFUUIDCreate(nil);//create a new UUID
- //get the string representation of the UUID
- NSString *uuidString = (NSString*)CFUUIDCreateString(nil, uuidObj);
- CFRelease(uuidObj);
- return [uuidString autorelease];
- }
判断iPhone 拍摄的相机是横拍还是纵拍的方法
可以根据 UIImage 的 UIImageOrientation 属性判断 iPhone 拍摄照片时的横/纵属性,代码
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
if(image.imageOrientation==UIImageOrientationLeft||image.imageOrientation==UIImageOrientationRight){
}else{
}
}
获取当前硬件可用内存
#import "UIDeviceHelper.h"
#include <sys/sysctl.h>
#include <mach/mach.h>
@implementation UIDevice (Helper)
- (double)availableMemory {
vm_statistics_data_t vmStats;
mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);
if(kernReturn != KERN_SUCCESS) {
return NSNotFound;
}
return ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;
}
本文详细介绍了如何通过Objective-C和Swift实现判断运行应用的iPhone设备是否为iOS 4或iOS 3,并获取当前硬件可用内存大小。此外,还提供了判断iPhone拍摄的相机是横拍还是纵拍的方法,通过检查UIImage的UIImageOrientation属性。代码实例清晰易懂,适合iOS开发者深入学习。

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



