摘要: 本文来源:http://www.wuleilei.com/Blog/240网络请求,需要在请求完成后回调delegate的方法。然而回调时经常遇到这种情况:delegate已经被释放,这时调用其方法则会引起crash。objc的runtime中有两种判断类型的方式比较靠谱,他们可以直接取得任意一个objc_object(和id是完全一样的数据类型)的类或者类名。其函数如下://Returns the class name of a given object.const char *object_getClassName(id obj); //Returns the class of an ob 阅读全文
posted @ 2012-04-27 11:45 小菜比 阅读(392) 评论(0) 推荐(0) 编辑
摘要: [UIViewbeginAnimations:nilcontext:nil]; [UIViewsetAnimationDuration:2]; [UIViewsetAnimationDelegate:self]; CAKeyframeAnimation * animation;animation = [CAKeyframeAnimationanimationWithKeyPath:@"transform"];animation.duration = 2;animation.delegate = self;animation.removedOnCompletion = NO; 阅读全文
posted @ 2012-03-31 16:25 小菜比 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 1.UILongPressGestureRecognizer2.在touchBegan里面[self performSelector:@selector(longPressMethod:) withObject:nil afterDelay:longPressTime]然后在 end 或cancel里做判断,如果时间不够长按的时间调用 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(longPressMethod:) object:nil]取消began里的方法 阅读全文
posted @ 2012-02-17 15:43 小菜比 阅读(124) 评论(0) 推荐(0) 编辑
摘要: -(UIView *)findView:(UIView *)aView withName:(NSString *)name{ Class cl = [aView class]; NSString *desc = [cl description]; NSLog(@"********%@",desc); if ([name isEqualToString:desc]) return aView; for (NSUInteger i = 0; i < [aView.subviews count]; i++) { UIView *subView = [aView.subvie 阅读全文
posted @ 2011-07-12 12:05 小菜比 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 大多数时候我们使用uiimage时候用[UIImage imageNamed:@"xxxx.png"];但是这样会创建一个自动释放池,一般用路径来初始化uiimageUIImage *image=[[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"xxx.png"]]; UIImageView *imageView = [[UIImageView alloc] initWithImage:i 阅读全文
posted @ 2011-07-12 11:48 小菜比 阅读(465) 评论(0) 推荐(0) 编辑
摘要: seachBar=[[UISearchBar alloc] init]; //修改搜索框背景 seachBar.backgroundColor=[UIColor clearColor]; //去掉搜索框背景 //1. [[searchbar.subviews objectAtIndex:0]removeFromSuperview]; //2. for (UIView *subview in seachBar.subviews) { if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) 阅读全文
posted @ 2011-07-11 17:18 小菜比 阅读(6177) 评论(1) 推荐(0) 编辑
摘要: NSString *oneStr =@"one+two";NSString *twoStr =CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)oneStr, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8);[request setHTTPBody:[twoStr dataUsingEncoding:NSUTF8StringEncoding]];[twoStr release];[u 阅读全文
posted @ 2011-07-08 15:08 小菜比 阅读(256) 评论(0) 推荐(0) 编辑