随笔分类 -  Objective-C

摘要://加入下面两行代码即可[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];[[UINavigationBar appearance] s... 阅读全文
posted @ 2015-01-20 09:12 小小有 阅读(253) 评论(0) 推荐(0)
摘要://date根据formatter转换成string+(NSString*)dateToString:(NSString *)formatter date:(NSDate *)date{ NSDateFormatter *dateFormatter = [[NSDateFormatter al... 阅读全文
posted @ 2014-08-06 13:19 小小有 阅读(186) 评论(0) 推荐(0)
摘要:1、随机数的使用1)、arc4random() 比较精确不需要生成随即种子 使用方法 : 通过arc4random() 获取0到x-1之间的整数的代码如下: intvalue=arc4random()%x; 获取1到x之间的整数的代码如下: intvalue=(arc4random()%x)+1; ... 阅读全文
posted @ 2014-07-03 15:48 小小有 阅读(211) 评论(0) 推荐(0)
摘要:直接上代码:// 触摸背景,关闭键盘- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; UIView *view = (UIView... 阅读全文
posted @ 2014-06-24 11:46 小小有 阅读(237) 评论(0) 推荐(0)
摘要:在Objective-C中,可以使用#import和@class来引用别的类型, 但是你知道两者有什么区别吗?@class叫做forward-class, 你经常会在头文件的定义中看到通过@class的引用,原因就是当你只用@class来引入一个类时, 编译器知道有这么一个类,也就是说它能识别Eng... 阅读全文
posted @ 2014-05-28 16:56 小小有 阅读(228) 评论(0) 推荐(0)
摘要:一:确认网络环境3G/WIFI1. 添加源文件和framework开发Web等网络应用程序的时候,需要确认网络环境,连接情况等信息。如果没有处理它们,是不会通过Apple的审查的。Apple 的 例程 Reachability 中介绍了取得/检测网络状态的方法。要在应用程序程序中使用Reachabi... 阅读全文
posted @ 2014-05-27 17:19 小小有 阅读(266) 评论(0) 推荐(0)
摘要:oc中单例模式可以使用以下方法来实现+ (YourClass *)sharedInstance{ static dispatch_once_t once; static YourClass *sharedInstance = nil; dispatch_once(&once, ^ ... 阅读全文
posted @ 2014-05-26 17:02 小小有 阅读(289) 评论(0) 推荐(0)
摘要://16进制颜色(html颜色值)字符串转为UIColor+(UIColor *) hexStringToColor: (NSString *) stringToConvert{ NSString *cString = [[stringToConvert stringByTrimmingCh... 阅读全文
posted @ 2014-05-23 13:42 小小有 阅读(392) 评论(0) 推荐(0)
摘要:不可变数组 ——NSArray常用的初始化一个数组: NSArray *array1 = [[NSArray alloc] init]; NSArray *array2 = [NSArray array]; //对于上述两个方法,在NSArray中用的很少,因为这是一个空数组,它的值是不可... 阅读全文
posted @ 2014-05-04 09:37 小小有 阅读(898) 评论(0) 推荐(0)
摘要://1、创建常量字符串。NSString *astring = @"This is a String!";//2、创建空字符串,给予赋值。NSString *astring = [[NSString alloc] init]; astring = @"This is a String!"; [ast... 阅读全文
posted @ 2014-05-04 09:25 小小有 阅读(467) 评论(0) 推荐(0)