现在的位置: 首页 > 综合 > 正文

IOS-小技巧

2018年02月02日 ⁄ 综合 ⁄ 共 398字 ⁄ 字号 评论关闭

 //获取版本号

NSString *versionNum = [[[NSBundle mainBundle] infoDictionary]
                                    objectForKey:(NSString *)kCFBundleVersionKey];

//判断是否为iphone设备

[[UIDevicecurrentDevice]userInterfaceIdiom] ==UIUserInterfaceIdiomPhone

//判断真机或者模拟器宏定义

#if TARGET_IPHONE_SIMULATOR

//模拟器

#elif TARGET_OS_IPHONE

//真机

#endif

如果要收回键盘,可使用

[self.viewendEditing:YES]; 

快速的定义一个weakSelf

#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;

抱歉!评论已关闭.