01 2012 档案

摘要:@dynamic 意思是由开发人员提供相应的代码:对于只读属性需要提供 setter,对于读写属性需要提供 setter 和 getter。 @synthesize 意思是,除非开发人员已经做了,否则由编译器生成相应的代码,以满足属性声明。查阅了一些资料确定@dynamic的意思是告诉编译器,属性的获取与赋值方法由用户自己实现, 不自动生成。 @dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else 阅读全文
posted @ 2012-01-29 15:51 alex hu 阅读(2250) 评论(0) 推荐(0) 编辑
摘要:object-c中的protocol有点类似于c#中的委托和接口,下面用实例来说明:从远程下载图片到UIImage,然后再180度转换图片View Code #import <Foundation/Foundation.h>#define TIMEOUT_SEC 20.0@interface TSHttpClient : NSObject { NSURLConnection *connection; NSMutableData *recievedData; int statusCode; BOOL contentTypeIsXml; ... 阅读全文
posted @ 2012-01-25 12:29 alex hu 阅读(820) 评论(0) 推荐(0) 编辑
摘要:1.常见问题 a,为什么创建的UIButton点击不了,没有反应? 原因可能是:UIView在initWithFrame时候没有小了,超出UIWindow区域。 b, presentModalViewController动画效果 modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self dismissModalViewControllerAnimated:YES]; c,为什么NSDictionary的键值总是null 初始化数字的时候最好不要直接赋值,要像这样[NSNumber numberWithIn... 阅读全文
posted @ 2012-01-21 23:23 alex hu 阅读(410) 评论(0) 推荐(0) 编辑
摘要:网页上面常用的Jquery广告控件(slideshow)是通过div+jquery来实现,ios上面实现主要通过UIPageControl+UIScrollView来结合实现,效果如下图:源码如下:1 #import <Foundation/Foundation.h>2 @class SlideView;3 4 @protocol SlideScrollDelegate <NSObject>5 6 -(void)slideshowDidChangeCurrentView:(SlideView *)slideview CurrentPage:(int) currentPa 阅读全文
posted @ 2012-01-21 23:23 alex hu 阅读(887) 评论(0) 推荐(0) 编辑
摘要:ASIHTTPRequest用法不多介绍,网上一堆,实例如图1 #import <UIKit/UIKit.h>2 #import "MainView.h"3 4 @interface AppDelegate : UIResponder <UIApplicationDelegate>5 6 @property (strong, nonatomic) UIWindow *window;7 @property (strong, retain) MainView *viewController;8 9 @end 1 - (void)dealloc 2 { 3 阅读全文
posted @ 2012-01-21 23:23 alex hu 阅读(674) 评论(0) 推荐(0) 编辑
摘要:1. NSUserDefaults 个人认为ios这个方法有点类似于c#中Properties.Settings.Default,NSUserDefaults只支持: NSString, NSNumber, NSDate, NSArray, NSDictionary. 创建一个user defaults方法有多个,最简单得快速创建方法: NSUserDefaults *accountDefaults = [NSUserDefaults standardUserDefaults]; 添加数据到 user defaults: [accountDefaults setObject:name... 阅读全文
posted @ 2012-01-21 23:22 alex hu 阅读(401) 评论(0) 推荐(0) 编辑
摘要:NSLog(@"Hello, World!"); NSDictionary *myDic=[[NSDictionary alloc]initWithObjectsAndKeys:@"张三",@"name",@"李四",@"name", nil]; NSUInteger count = [myDic count]; NSLog(@"词典的数量为: %lu",count); NSEnumerator * myEnumerator = [myDic keyEnumerator]; 阅读全文
posted @ 2012-01-21 23:22 alex hu 阅读(356) 评论(0) 推荐(0) 编辑
摘要:1. NSClassFromString 这个方法判断类是否存在,如果存在就动态加载的,不存为就返回一个空对象; id myObj = [[NSClassFromString(@"MySpecialClass") alloc] init]; 正常情况下等价于:id myObj = [[MySpecialClass alloc] init]; 优点:1, 弱化连接,因此并不会把没有的Framework也link到程序中。2,不需要使用import,因为类是动态加载的,只要存在就可以加载。因此如果你的toolchain中没有某个类的头文件定义,而你确信这个类是可以用的,那么也可 阅读全文
posted @ 2012-01-21 23:22 alex hu 阅读(581) 评论(0) 推荐(0) 编辑