02 2012 档案
摘要:iPhone应用程序编程指南分类:iOS-中级2011-09-27 15:091000人阅读评论(0)收藏举报介绍请注意:本文档之前命名为iPhone OS编程指南。iPhone SDK为创建iPhone的本地应用程序提供必需的工具和资源。在用户的Home屏幕上,iPhone的本地应用程序表示为图标。它们和运行在Safari内部的web应用程序不同,在基于iPhone OS的设备上,它们作为独立的执行程序来运行。本地应用程序可以访问iPhone和iPod Touch的所有特性,比如加速计、位置服务、和多点触摸接口,正是这些特性使设备变得更加有趣。本地应用程序还可以将数据保存在本地的文件系统中,
阅读全文
摘要:1.最常见的原因是 contentSize 这个属性,比uiscrollview的frame要小, 无需滚动, 自然就滚动不了。 scrollenabled 这个属性,标识着是否允许滚动,要言设成yes另外还有一些比较隐蔽的原因. 如果这个scrollView是在IB里面生成的话,还得手动设置它的contentSize,并且不能在initWithNibName:bundle:里面设置,因为The nib file you specify is not loaded right away. It is loaded the first time the view controller’s v..
阅读全文
摘要:the View Management CycleThe steps that occur during the load cycle are as follows:Some part of your application asks for the view in the view controller’sviewproperty.If the view is not currently in memory, the view controller calls itsloadViewmethod.TheloadViewmethod does one of the following:If y
阅读全文
摘要:以前对于为什么在viewDidUnload将property设为nil就可以将内存释放防止内存泄漏感到疑惑.今天看文档的时候终于想明白了.首先我们来看一个例子:1 @interface Counter : NSObject 2 {3 NSNumber *_count;4 }5 @property (nonatomic, retain) NSNumber *count;6 @end;count property的access method 相当于下面两个methods: 1 - (NSNumber *)count 2 { 3 return _count; 4 } 5 6 - (...
阅读全文
摘要:For a detached nib file, the actual loading of the nib file occurs automatically when theviewproperty of the view controller object is accessed and the view is not currently in memory. The defaultloadViewmethod uses thenibNameandnibBundleproperties to locate the desired nib file and load its content
阅读全文
摘要:You Don’t Own Objects Returned by ReferenceSome methods in Cocoa specify that an object is returned by reference (that is, they take an argument of type ClassName** or id*). A common pattern is to use an NSError object that contains information about an error if one occurs, as illustrated by initWit
阅读全文
摘要:UITextView has square edges, and looks ugly compared to a UITextField!Unfortunately, there isn’t an option to give the UITextView a nice border. There are various ways to do this, such as creating your own background image for the UITextView, but I have found a relatively easy way to do it – and one
阅读全文
摘要:googlecode里面很多优秀的开源代码,其中一些完整的产品项目对于我们iOS个人开发者来说很有参考价值.下面分享一下从googlecode中check out source code 的方法1、google code的网址是 http://code.google.com/hosting/2、找到所想下载的代码后,到source里找到 svn checkout http://5dice.googlecode.com/svn/trunk/ 5dice-read-only 这样的字段3、打开终端 输入如下命令: 1) cd Desktop //这个是切换到桌面 2) sudo mkdir 5di
阅读全文
摘要:1 time_t convertTimeStamp(NSString *stringTime) 2 { 3 time_t createdAt; 4 struct tm created; 5 time_t now; 6 time(&now); 7 8 if (stringTime) { 9 if (strptime([stringTime UTF8String], "%a %b %d %H:%M:%S %z %Y", &created) == NULL) {10 strptime([stringTime ...
阅读全文
摘要:时间日期格式化符号:%y 两位数的年份表示(00-99)%Y 四位数的年份表示(000-9999)%m 月份(01-12)%d 月内中的一天(0-31)%H 24小时制小时数(0-23)%I 12小时制小时数(01-12)%M 分钟数(00=59)%S 秒(00-59)%a 本地简化星期名称%A 本地完整星期名称%b 本地简化的月份名称%B 本地完整的月份名称%c 本地相应的日期表示和时间表示%j 年内的一天(001-366)%p 本地A.M.或P.M.的等价符%U 一年中的星期数(00-53)星期天为星期的开始%w 星期(0-6),星期天为星期的开始%W 一年中的星期数(00-53)星期一为
阅读全文
摘要:UTF8String 这个方法将NSString转为C语言中以'\0'结尾的字符串. Returns a null-terminated UTF8 representation of the receiver. - (const char *)UTF8String Return Value A null-terminated UTF8 representation of the receiver. Discussion The returned C string is automatically freed just as a returned object...
阅读全文
摘要:函数原型:char *asctime(const struct tm *tblock);功能说明:将tm结构类型时间日期转换为ASCII码。头文件:参数说明:语法:asctime[必要参数]必要参数的具体说明如下:tblock:待转换的时间指针,tblock为一tm结构型指针。返回值:返回由tm结构中的日期和时间转换成的字符串的地址,该字符串的形式定义如下:DDD MMM dd hh:mm:ss YYYY各字符的意义:DDD一星期的某一天,如MonMMM月份,如Jandd月中一天(1,2,……,31)hh小时(1,2,……,24)mm分钟(1,2,……,59)ss秒数(1,2,……,59)YY
阅读全文
摘要:包含文件:#ifndef__TIME_T#define__TIME_T /*避免重复定义time_t*/typedef long time_t; /*时间值time_t 为长整型的别名*/#endif既然time_t实际上是长整型,到未来的某一天,从一个时间点(一般是1970年1月1日0时0分0秒)到那时的秒数(即日历时间)超出了长整形所能表示的数的范围怎么办?对time_t数据类型的值来说,它所表示的时间不能晚于2038年1月18日19时14分07秒。为了能够表示更久远的时间,一些编译器厂商引入了64位甚至更长的整形数来保存日历时间。比如微软在Visual C++中采用了__time64_t
阅读全文
摘要:1 struct tm { 2 int tm_sec; /* seconds */ 3 int tm_min; /* minutes */ 4 int tm_hour; /* hours */ 5 int tm_mday; /* day of the month */ 6 int tm_mon; /* month */ 7 ...
阅读全文
摘要:①使用gmtime函数或localtime函数将time_t类型的时间日期转换为struct tm类型:使用time函数返回的是一个long值,该值对用户的意义不大,一般不能根据其值确定具体的年、月、日等数据。gmtime函数可以方便的对time_t类型数据进行转换,将其转换为tm结构的数据方便数据阅读。gmtime函数的原型如下:struct tm *gmtime(time_t *timep);localtime函数的原型如下:struct tm *localtime(time_t *timep);将参数timep所指的time_t类型信息转换成实际所使用的时间日期表示方法,将结果返回到结构
阅读全文
摘要:1 NSString *src = @"<a href="http://weibo.com" rel="nofollow">新浪微博</a>" 2 NSRange r=[src rangeOfString:@"<a href"]; 3 if (r.location!=NSNotFound) { 4 5 NSRange start=[src rangeOfString:@"<a href=\""]; 6 if (start.location!=NSNo
阅读全文
摘要:1 uinavigationbar: 2 UIImage *img = [UIImage imageNamed:@"background.png"]; 3 navBar.layer.contents = (id)img.CGImage; 4 5 toolbar: 6 UIImageView *barBackgroudView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320,44)]; 7 barBackgroudView.image = [UIImage imageNamed:@"tbackgro
阅读全文
摘要:含义 ENCTYPE="multipart/form-data" 说明:通过 http 协议上传文件 rfc1867协议概述,jsp 应用举例,客户端发送内容构造1、概述在最初的 http 协议中,没有上传文件方面的功能。 rfc1867 (http://www.ietf.org/rfc/rfc1867.txt) 为 http 协议添加了这个功能。客户端的浏览器,如 Microsoft IE, Mozila, Opera 等,按照此规范将用户指定的文件发送到服务器。服务器端的网页程序,如 php, asp, jsp 等,可以按照此规范,解析出用户发送来的文件。Microso
阅读全文
摘要:加载过程:一般情况下调用 init方法或者调用initWithNibName方法实例化UIViewController, 不管调用哪个方法都为调用initWithNibName(方法定义如下)- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil接着会调用loadView方法来生成UIViewController.view- (void)loadView然后调用 viewDidLoad方法- (void)viewDidLoad如果loadView不能生成UIViewController.v
阅读全文
摘要:1 lazytable 例子 2 3 // Set appIcon and clear temporary data/image 4 UIImage *image = [[UIImage alloc] initWithData:self.activeDownload]; 5 6 if (image.size.width != kAppIconHeight && image.size.height != kAppIconHeight) 7 { 8 CGSize itemSize = CGSizeMake(kAppIconHeight, kAp...
阅读全文
摘要:计算string串的像素长度:1 CGSize polLabelSize = [polName sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];2 CGSize podLabelSize = [podName sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];3 float polLabelWidth = (po
阅读全文
摘要:一.C语言的可变参数函数实现首先看一下C语言中的可变参数是怎么实现的:C语言支持va函数,作为C语言的扩展--C++同样支持va函数,但在C++中并不推荐使用,C++引入的多态性同样可以实现参数个数可变的函数。不过,C++的重载功能毕竟只能是有限多个可以预见的参数个数。比较而言,C中的va函数则可以定义无穷多个相当于C++的重载函数,这方面C++是无能为力的。va函数的优势表现在使用的方便性和易用性上,可以使代码更简洁。C编译器为了统一在不同的硬件架构、硬件平台上的实现,和增加代码的可移植性,提供了一系列宏来屏蔽硬件环境不同带来的差异。ANSI C标准下,va的宏定义在stdarg.h中,它们
阅读全文
摘要:NSLog([[UIDevice currentDevice] name]); // Name of the phone as named by userNSLog([[UIDevice currentDevice] uniqueIdentifier]); // A GUID like stringNSLog([[UIDevice currentDevice] systemName]); // "iPhone OS"NSLog([[UIDevice currentDevice] systemVersion]); // "2.2.1"NSLog([[UID
阅读全文
摘要:- (void)textViewDidChangeSelection:(UITextView*)textView{NSRangerange;range.location=0;range.length=0;textView.selectedRange= range;}以上是当在UITextView中输入文字的时候,光标都从最初点开始。
阅读全文