Fork me on GitHub
上一页 1 ··· 49 50 51 52 53 54 55 56 57 ··· 125 下一页

2012年3月25日

摘要: CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();CGContextRef context = CGBitmapContextCreate(NULL,pageSize.width, /* size_t width */pageSize.height, /* size_t height */8,/* bits per component 32/4 */pageSize.width * 4,/* bytes per row 每行字节数,每一个位图像素的代表是4个字节 */colorSpace, /* CGCo... 阅读全文
posted @ 2012-03-25 09:20 pengyingh 阅读(356) 评论(0) 推荐(0)
摘要: NSImage初始化NSImage *image = [NSImage alloc] initWithContentsOfFile:path];[image setScalesWhenResized:YES];[image setSize:NSMakeSize(1000.0, [image size].height * (1000.0/[image size].width))];使用NSImage的lockFocus方法可以把NSGraphicsContext设置到它身上,原来是在当前窗体NSImage *canvas = [NSImage alloc] initWithSize:canvas 阅读全文
posted @ 2012-03-25 08:25 pengyingh 阅读(809) 评论(0) 推荐(0)
摘要: ask:I have a buffer of RGB unsigned char that I would like converted into a bitmap file, does anyone know how?My RGB float is of the following formatR [(0,0)], G[(0,0)], B[(0,0)],R [(0,1)], G[(0,1)], B[(0,1)], R [(0,2)], G[(0,2)], B[(0,2)] .....The values for each data unit ranges from 0 to 255. any 阅读全文
posted @ 2012-03-25 08:07 pengyingh 阅读(7066) 评论(0) 推荐(0)

2012年3月23日

摘要: - (CGSize)sizeThatFits:(CGSize)size; // return 'best' size to fit given size. does not actually resize view. Default is return existing view size- (void)sizeToFit; // calls sizeThatFits: with current view bounds and changes bounds size.sizeThatFits:Asks the view to calculate and return th... 阅读全文
posted @ 2012-03-23 17:30 pengyingh 阅读(21746) 评论(0) 推荐(1)
摘要: The iphone app im writing displays an html page, i would like to add a search feature where the user can search for instances for the keyword and highlight them (like in firefox using ctrl+F)what's the best way to do this? in objective-c? would this be even possible with javascript?Please point 阅读全文
posted @ 2012-03-23 15:08 pengyingh 阅读(932) 评论(0) 推荐(0)
摘要: 1.循环滚动每次滚动后都将scrollview的offset设置为中间的一页若本次滚动是向前一页滚动,则把三页都向后放置,最后一页放到开头若本次滚动是向后一页滚动,则把三页都向前放置,第一页放到末尾初始化UISCrollViewfloat x,y,width,height;x = WIDTH_OFF_SET;y = HEIGHT_OFF_SET;width = WIDTH_OFF_SET;height = SCROLLVIEW_HEIGHT;for (int j=0; j<3; j++) {UIView *view = [[UIView alloc] initWithFrame:CGRe 阅读全文
posted @ 2012-03-23 14:59 pengyingh 阅读(13611) 评论(1) 推荐(0)
摘要: 不用#if:NSString*deviceType =[UIDevice currentDevice].model;if([deviceType isEqualToString:@"iPhone"]){ //iPhone}elseif([deviceType isEqualToString:@"iPod touch"]){ //iPod Touch}else{ //iPad}使用#if:#ifdefUI_USER_INTERFACE_IDIOM //注意此处没有括号//UI_USER_INTERFACE_IDIOM 是枚举类型结构体,内有typedefe 阅读全文
posted @ 2012-03-23 11:18 pengyingh 阅读(1427) 评论(0) 推荐(0)

2012年3月21日

摘要: 1.Command-Option-Shift-K to clean out the build folder XCode4.2 finder中找到 /Users/apple/Library/Developer/Xcode (注:Library资源库是隐藏的文件夹) 里面有DerivedData和Snapshots两个文件夹,删除里面文件即可 Removeallits contents because there's a bug where Xcode will run an old version of your project that's in there somewher 阅读全文
posted @ 2012-03-21 00:35 pengyingh 阅读(27121) 评论(0) 推荐(2)
摘要: 今天晚上开始使用Xcode4,初窥历程如下。一、下载安装Xcode4因为我需要让Xcode4和老版本共存,在安装Xcode4时选择其他安装路径,安装成功后在xcode4安装目录下改名Xcode.app为Xcode4.app以区分老版本,随便找一个xcodeproj文件,右键GetInfo,在Open with里面选择Xcode4并点击Change All以设置文件类型关联。二、熟悉界面打开Xcode,大概浏览下界面的变化,到处乱点下看是啥东西,把Xcode菜单浏览一遍。有空的话可以看看帮助文档里面关于源代码管理的部分。试着建一个HelloWorld项目,并操作下IB链接。三、配置代码编辑器的字 阅读全文
posted @ 2012-03-21 00:24 pengyingh 阅读(1677) 评论(0) 推荐(0)

2012年3月20日

摘要: 在iOS开发中,和货币价格计算相关的,需要注意计算精度的问题。即使只是两位小数,也会出现误差。使用float类型运算,是完全不够的。经过一番测试,最后选择使用系统提供的API的NSDecimalNumber来进行更好的解决。作为一个对外的库,鉴于版本延续,我们保留对外的flaot的类型,不改变接口,选择进行内部适配。以下是一些基本的测试,原始数据float a = 0.01;int b = 99999999;double c = 0.0;1:使用浮点运算,c = a*b;NSLog(@"%f",c);NSLog(@"%.2f",c);使用double类型 阅读全文
posted @ 2012-03-20 23:54 pengyingh 阅读(3384) 评论(1) 推荐(1)
上一页 1 ··· 49 50 51 52 53 54 55 56 57 ··· 125 下一页

导航