上一页 1 2 3 4 5 6 7 ··· 20 下一页
摘要: note:I just create test app and test. So for devices with out retina: ImageName.png - For iPhone/iPod ImageName~ipad.png -- For iPad For devices with retina display: ImageName@2x~ipad.png -- For iPad ImageName@2x.png - For iPhone/iPod And you can still use @2x if you iPhone high resolution image and 阅读全文
posted @ 2012-03-14 14:25 Gang.Wang 阅读(391) 评论(0) 推荐(0) 编辑
摘要: 可以调用UIViewController的isViewLoaded方法来判断视图是否已经装载完成。 阅读全文
posted @ 2012-01-14 16:18 Gang.Wang 阅读(748) 评论(0) 推荐(0) 编辑
摘要: 在ios,blocks是对象,它封装了一段代码,这段代码可以在任何时候执行。Blocks可以作为函数参数或者函数的返回值,而其本身又可以带输入参数或返回值。它和传统的函数指针很类似,但是有区别:blocks是inline的,并且它对局部变量是只读的。Blocks的定义: int (^Multiply)(int, int) = ^(int num1, int num2) {return num1 * num2;};定义了一个Multiply的blocks对象,它带有两个int参数,返回int。等式右边就是blocks的具体实现,注意{}blocks体里的;。Blocks可以访问局部变量,但是不能 阅读全文
posted @ 2012-01-04 21:52 Gang.Wang 阅读(4650) 评论(0) 推荐(1) 编辑
摘要: 获取省略号指定的参数在函数体中声明一个va_list,然后用va_start函数来获取参数列表中的参数,使用完毕后调用va_end()结束。像这段代码:voidTestFun(char* pszDest, int DestLen, const char* pszFormat, ...){va_listargs;va_start(args,pszFormat);_vsnprintf(pszDest, DestLen, pszFormat,args);va_end(args);}4.va_start使argp指向第一个可选参数。va_arg返回参数列表中的当前参数并使argp指向参数列表中的下一个 阅读全文
posted @ 2012-01-04 21:00 Gang.Wang 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 下面代码示范了如何自动计算UILabel尺寸以适应文本的展示:NSString * myText = [NSString stringWithString:@"some text"];//获取到文本大大小CGFloat constrainedSize = 265.0f; //其他大小也行UIFont * myFont = [UIFont fontWithName:@"Arial" size:19]; // UILabel使用的字体CGSize textSize = [myText sizeWithFont: myFont constrainedToSiz 阅读全文
posted @ 2011-12-08 14:10 Gang.Wang 阅读(1639) 评论(0) 推荐(0) 编辑
摘要: Object-C 中的Selector 概念Andrew Huang<bluedrum@163.com> 转载请注明作者和联络方式 在iphone程序中会大量看到@selector这样的用法。<<iphone开发基础>花了很大一个篇幅来解析这个语法,但是不知 是翻译问题,还是解释过细,不大看得懂,很是不给力.直到程序用这个语法,并且仔细看了一些解析文章。才明白这一语法。 简而言之,你可以理解 @selector()就是取类方法的编号,他的行为基本可以等同C语言的中函数指针,只不过C语言中,可以把函数名直接赋给一个函数指针,而Object-C的类不能直接应用函数指针 阅读全文
posted @ 2011-12-05 11:29 Gang.Wang 阅读(445) 评论(0) 推荐(0) 编辑
摘要: @interface YkMainViewController : UIViewController <YkFlipsideViewControllerDelegate>{ NSOperationQueue *operationQueue; BOOL b_init;}@interface MyTask : NSOperation{ int operationId;}@property int operationId;@end#import "MyTask.h"@implementation MyTask@synthesize operationId;- (voi 阅读全文
posted @ 2011-11-24 11:30 Gang.Wang 阅读(1038) 评论(1) 推荐(0) 编辑
摘要: View Code 1 @interface ClassC : NSObject { 2 @private 3 4 } 5 @end 6 7 @implementation ClassC 8 9 -(void) dealloc10 {11 [super dealloc];12 13 }14 @end15 16 @interface ClassB : NSObject {17 @private18 ClassC * class_c;19 }20 21 @property(nonatomic, retain) ClassC * classc;22 @end... 阅读全文
posted @ 2011-11-14 11:42 Gang.Wang 阅读(551) 评论(0) 推荐(0) 编辑
摘要: View Code @interface Singleton : NSObject {}+ (Singleton *) sharedInstance;- (void) operation;@endView Code #import "Singleton.h"@implementation Singletonstatic Singleton *sharedSingleton_ = nil;- (void) operation{ // do something NSLog(@"Singleton");}+ (Singleton *) sharedInstan 阅读全文
posted @ 2011-10-21 10:43 Gang.Wang 阅读(377) 评论(0) 推荐(0) 编辑
摘要: View Code @interface BrandingFactory : NSObject {}+ (BrandingFactory *) factory;- (UIView *) brandedView;- (UIButton *) brandedMainButton;- (UIToolbar *) brandedToolbar;@endView Code #define USE_ACME@implementation BrandingFactory+ (BrandingFactory *) factory{#if defined (USE_ACME) return [[[Acme... 阅读全文
posted @ 2011-10-21 10:30 Gang.Wang 阅读(405) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 20 下一页