11 2012 档案
摘要:在iOS3.2以后的系统中,苹果就提供了键盘使用的API以及Demo程序——“KeyboardAccessory”。 处理键盘事件的正确方法是这样的:(包括获取键盘的位置以及键盘弹出和消失动画的时间) 1)在要使用键盘的视图控制器中(既viewDidLoad中),接收键盘事件的通知:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];[[NSNotificatio..
阅读全文
摘要: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...
阅读全文
摘要:小细节: 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 ..
阅读全文
摘要: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:
阅读全文
摘要:1. 如何判断用户点击的按钮UIAlertView有一个委托UIAlertViewDelegate ,继承该委托来实现点击事件头文件:@interfaceMyAlertViewViewController : UIViewController<UIAlertViewDelegate> {}- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;-(IBAction) buttonPressed;@end源文件:-(IBAction) buttonPressed{UIA
阅读全文
摘要:1、修改UISearchBar的背景颜色UISearchBar是由两个subView组成的,一个是UISearchBarBackGround,另一个是UITextField. 要IB中没有直接操作背景的属性。方法是直接将 UISearchBarBackGround移去seachBar=[[UISearchBaralloc]init]; seachBar.backgroundColor=[UIColorclearColor]; for(UIView*subviewinseachBar.subviews){if([subviewisKindOfClass:NSClassFromString(@&q
阅读全文
摘要: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
阅读全文
摘要:系统至ios6之后,关于图片拉伸的方法已经扩展至3个函数: 1.ios4提供的方法: - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight 这个函数是UIImage的一个实例函数,它的功能是创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是不拉伸区域距离左边框的宽度,第二个参数是不拉伸区域距离上边框的宽度,其操作本质是对一个像素的复制拉伸,故没有渐变效果,这也是其缺点所在。 参数的意义是,如果参数指定10,5。那么...
阅读全文
摘要://测量字符串长度, 两个参数都可以固定或者不固定 CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(150.0f, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];2.换行方式UILineBreakModeWordWrap=0,以单词为单位换行,以单位为单位截断。UILineBreakModeCharacterWrap,以字符为单位换行,以字符为单位截断。UILineBreakModeClip,以单词为单位换行。以字符为单位截断。UILineBreakMo..
阅读全文
摘要:1.获取系统得时间与日期NSString* date;NSDateFormatter* formatter = [[NSDateFormatteralloc]init]; [formattersetDateFormat:@"YYYY-MM-dd%20hh:mm:ss"]; date = [formatterstringFromDate:[NSDatedate]];2.分开获得/获得系统时间NSDate*senddate=[NSDatedate];NSDateFormatter*dateformatter=[[NSDateFormatteralloc]init];[datef
阅读全文
摘要://button的长按事件 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizeralloc] initWithTarget:selfaction:@selector(btnLong:)]; //长按时间 longPress.minimumPressDuration = 0.8; [button addGestureRecognizer:longPress];#pragma mark -#pragma mark Table Delegate Methods- (NSInteger)tableVie...
阅读全文
摘要:1.//用画图的方式设置圆角mImageView.image=[UIImage imageNamed:@"bg1.png"]; mImageView.frame=CGRectMake(center.x-radius, center.y-radius, 2*radius, 2*radius); mImageView.layer.cornerRadius=radius;//设置圆角半径 mImageView.layer.masksToBounds=YES; [mImageView.layer setBorderWidth:1];//设置边框宽度 [mImageView.laye
阅读全文
摘要://设置边框样式,只有设置了才会显示边框样式 text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, UITextBorderStyleRoundedRect } UITextBorderStyle;//设置输入框的背景颜色,此时设置为白色如果使用了自定义的背景图片边框会被忽略掉 text.backgroundColor = [UIColor whiteColor];//设...
阅读全文
摘要:1.objective-c中的数字对象都有哪些,简述它们与基本数据类型的区别是什么2.用NSLog函数输出一个浮点类型,结果四舍五入,并保留一位小数3.截取字符串”20|http://www.621life.com“ 中 ‘|’字符前面及后面的数据,分别输出它们4.objective-c中的词典对象、可变词典对象是哪个,初始化一个含有两个键值对的可变词典对象,并动态的添加和删除一条记录,输出第一条记录5.获取项目根路径,并在其下创建一个名称为userData的目录。6.在一个对象的方法里面:self.name = “object”;和name =”object”有什么不同吗?7.定义属性时,什
阅读全文

浙公网安备 33010602011771号