11 2011 档案
摘要:- (UIImage *)fixOrientation:(UIImage *)aImage { // No-op if the orientation is already correct if (aImage.imageOrientation == UIImageOrientationUp) return aImage; // We need to calculate the proper transformation to make the image upright. // We do it in 2 steps: Rotate if Left/R...
阅读全文
摘要:ASIHTTPRequest 是一款极其强劲的 HTTP 访问开源项目。让简单的 API 完成复杂的功能,如:异步请求,队列请求,GZIP 压缩,缓存,断点续传,进度跟踪,上传文件,HTTP 认证。在新的版本中,还加入了 Objective-C 闭包 Block 的支持,让我们的代码加轻简灵活。 下面就举例说明它的 API 用法。发起一个同步请求 同步意为着线程阻塞,在主线程中使用此方法会使应用Hang住而不响应任何用户事件。所以,在应用程序设计时,大多被用在专门的子线程增加用户体验,或用异步请求代替(下面会讲到)。 - (IBAction)grabURL:(id)sender { NSURL
阅读全文
摘要:UIResponder* nextResponder = [view nextResponder]; if ([nextResponder isKindOfClass:[UIViewController class]]) { return (UIViewController*)nextResponder; view是当前view,可以获取起controller;
阅读全文
摘要:1.创建并初始化创建UITextView的文件,并在.h文件中写入如下代码:#import <UIKit/UIKit.h>@interface TextViewController : UIViewController <UITextViewDelegate>{ UITextView *textView;}@property (nonatomic, retain) UITextView *textView;@end在.m文件中初始化这个textview,写入代码如下:self.textView = [[[UITextView alloc] initWithFrame:s
阅读全文
摘要:http://www.devdiv.com/thread-67521-1-1.html最近看这个比较多人用到,以前有使用过,现在,粘过来给大伙看看.注意:UIImageView的大小只能跟图片一样大.要不然取色不对.- (UIColor *) getPixelColorAtLocation:(CGPoint)point { UIColor* color = nil; CGImageRef inImage = self.image.CGImage; // Create off screen bitmap context to draw the image...
阅读全文
摘要:http://www.devdiv.com/thread-69786-1-1.htmlUILocalNotification *notification=[[UILocalNotification alloc] init]; if (notification!=nil) { NSDate *now=[NSDate new]; //notification.fireDate=[now addTimeInterval:period]; notification.fireDate = [now dateByAddingTimeInterval:period]; ...
阅读全文
摘要:http://www.cocoachina.com/bbs/read.php?tid=79243&page=e&#a如题~想要实现 javascript与objc的交互如何实现javascript调用objc内部的某一个接口呢?我是这样实现的例如某一入口<input type="button" id="enter" value="enter" onclick="testClick('printLog1:Log2:','ddddd','aaaaa');&qu
阅读全文
摘要:位运算 位运算的运算分量只能是整型或字符型数据,位运算把运算对象看作是由二进位组成的位串信息,按位完成指定的运算,得到位串信息的结果。位运算符有: &(按位与)、|(按位或)、^(按位异或)、~ (按位取反)。 其中,按位取反运算符是单目运算符,其余均为双目运算符。 位运算符的优先级从高到低,依次为~、&、^、|, 其中~的结合方向自右至左,且优先级高于算术运算符,其余运算符的结合方向都是自左至右,且优先级低于关系运算符。 (1)按位与运算符(&) 按位与运算将两个运算分量的对应位按位遵照以下规则进行计算: 0 & 0 = 0, 0 & 1 = 0, 1
阅读全文
摘要:http://www.cocoachina.com/bbs/read.php?tid=66260最普通动画://开始动画[UIView beginAnimations:nil context:nil]; //设定动画持续时间[UIView setAnimationDuration:2];//动画的内容frame.origin.x += 150;[img setFrame:frame];//动画结束[UIView commitAnimations];连续动画:一个接一个地显示一系列的图像NSArray *myImages = [NSArray arrayWithObjects:[UIImage
阅读全文
摘要:罗朝辉(http://blog.csdn.net/kesalin)转载请注明出处在入门级别的ObjC 教程中,我们常对从C++或Java 或其他面向对象语言转过来的程序员说,ObjC 中的方法调用(ObjC中的术语为消息)跟其他语言中的方法调用差不多,只是形式有些不同而已。譬如C++ 中的:Bird * aBird = new Bird();aBird->fly();在ObjC 中则如下:Bird * aBird = [[Bird alloc] init];[aBird fly];初看起来,好像只是书写形式不同而已,实则差异大矣。C++中的方法调用可能是动态的,也可能是静态的;而ObjC
阅读全文
摘要:代码如下,在UITableViewDataSource中设置- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{NSMutableArray *arr = [[[NSMutableArray alloc] initWithCapacity:0] autorelease];[arr addObject:@"{search}"];//等价于[arr addObject:UITableViewIndexSearch];return arr;}效果图:...http://www.cocoachin
阅读全文
摘要://检查数据库|| 复制数据库文件 NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *folderPath = [searchPaths objectAtIndex:0]; NSString *dbfilePath = [folderPath stringByAppendingPathComponent:DB_FILE_NAME]; if (![[NSFileManager defaultMan...
阅读全文
摘要://写入:NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);NSString *dataPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@”sqlite.sqlite”];NSData *image=UIImagePNGRepresentation([UIImage imageNamed:@"01_02.png"]);NSString *aaa=[[NSS
阅读全文
摘要:NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//多页面操作mydata.plist if (![[NSFileManager defaultManager] fileExistsAtPath:[[paths objectAtIndex:0] stringByAppendingPathComponent:@"mydata.plist"]]) { if ([[NSFileManager defaultManager] copyIt
阅读全文