摘要: iphone开发笔记和技巧总结1.iphone程序中实现截屏的一种方法在iphone程序中实现截屏的一种方法://导入头文件#import QuartzCore/QuartzCore.h//将整个self.view大小的图层形式创建一张图片image UIGraphicsBeginImageContext(self.view.bounds.size);[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];UIImage*image=UIGraphicsGetImageFromCurrentImageContext();U 阅读全文
posted @ 2013-01-07 16:09 Kristen 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 关于bundle作用在网上参考了两个博客,介绍如下:bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBundle.我们的程序是一个bundle. 在Finder中,一个应用程序看上去和其他文件没有什么区别. 但是实际上它是一个包含了nib文件,编译代码,以及其他资源的目录. 我们把这个目录叫做程序的main bundlebundle中的有些资源可以本地化.例如,对于foo.nib,我们可以有两个版本: 一个针对英语用户,一个针对法语用户.在bund 阅读全文
posted @ 2013-01-07 08:42 Kristen 阅读(2668) 评论(0) 推荐(0) 编辑
摘要: 在iOS3.2以后的系统中,苹果就提供了键盘使用的API以及Demo程序——“KeyboardAccessory”。 处理键盘事件的正确方法是这样的:(包括获取键盘的位置以及键盘弹出和消失动画的时间) 1)在要使用键盘的视图控制器中(既viewDidLoad中),接收键盘事件的通知:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];[[NSNotificatio.. 阅读全文
posted @ 2012-11-26 20:55 Kristen 阅读(1260) 评论(0) 推荐(0) 编辑
摘要: 1.获得键盘高度(UIView *)keyboardViewNotepad;{ NSArray *windows = [self windows]; for (UIWindow *window in [windows reverseObjectEnumerator]) { for (UIView *view in [window subviews]) { if (!strcmp(object_getClassName(view), "UIPeripheralHostView") || !strcmp(object_getCla... 阅读全文
posted @ 2012-11-23 20:00 Kristen 阅读(532) 评论(0) 推荐(0) 编辑
摘要: 小细节: 1. All the cells that are visible in the Table have its one UITableViewCell. 2. The UITableView only put cells in the reusable queue when they go outside the visual window. 3. In the first time, all the visible cells in the table are loaded using the Nib file (7,8, 10 times, depending on the .. 阅读全文
posted @ 2012-11-23 11:33 Kristen 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 1、创建常量字符串。NSString *astring = @"This is a String!";2、创建空字符串,给予赋值。NSString *astring = [[NSString alloc] init];astring = @"This is a String!";NSLog(@"astring:%@",astring);[astring release];3、在以上方法中,提升速度:initWithString方法NSString *astring = [[NSString alloc] initWithString: 阅读全文
posted @ 2012-11-21 21:17 Kristen 阅读(775) 评论(0) 推荐(0) 编辑
摘要: 1. 如何判断用户点击的按钮UIAlertView有一个委托UIAlertViewDelegate ,继承该委托来实现点击事件头文件:@interfaceMyAlertViewViewController : UIViewController<UIAlertViewDelegate> {}- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;-(IBAction) buttonPressed;@end源文件:-(IBAction) buttonPressed{UIA 阅读全文
posted @ 2012-11-21 18:06 Kristen 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 1、修改UISearchBar的背景颜色UISearchBar是由两个subView组成的,一个是UISearchBarBackGround,另一个是UITextField. 要IB中没有直接操作背景的属性。方法是直接将 UISearchBarBackGround移去seachBar=[[UISearchBaralloc]init]; seachBar.backgroundColor=[UIColorclearColor]; for(UIView*subviewinseachBar.subviews){if([subviewisKindOfClass:NSClassFromString(@&q 阅读全文
posted @ 2012-11-20 15:52 Kristen 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 1.取消cell点击变色cell.selectionStyle = UITableViewCellSelectionStyleNone;2.禁止边缘滑动(类似到顶端仍可拖动一小节)talbeview.bounces = NO;3.设置分界线颜色tableView.separatorColor =[UIColor clearColor];//透明,达到没有分界线效果4.标题Label加载在View上 return View时 才能实现自定义Label的frame, return label不能改变frame5.获得当前屏幕显示的所有行[mTableView indexPathsForVisibl 阅读全文
posted @ 2012-11-20 15:45 Kristen 阅读(711) 评论(0) 推荐(0) 编辑
摘要: 系统至ios6之后,关于图片拉伸的方法已经扩展至3个函数: 1.ios4提供的方法: - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight 这个函数是UIImage的一个实例函数,它的功能是创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是不拉伸区域距离左边框的宽度,第二个参数是不拉伸区域距离上边框的宽度,其操作本质是对一个像素的复制拉伸,故没有渐变效果,这也是其缺点所在。 参数的意义是,如果参数指定10,5。那么... 阅读全文
posted @ 2012-11-20 12:33 Kristen 阅读(1756) 评论(0) 推荐(0) 编辑