1.Multithreading
a.得到主队列
- (void)performSelectorOnMainThread:(SEL)aMethod
withObject:(id)obj
2. UIScrollView
a. 创建
scrollView.frame = CGRectMake(0,0,300,400);
scrollView.contentSize = CGSizeMake(500,1000);
subView.frame = CGRectMake(0,0,500,1000);
[scrollView addSubview:subView];
[self.view addSubview:scrollView];
b. 当前显示区域
CGPoint point = scrollView.contentOffset;
CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:subView];
c. 滚动到某个区域
- (void)scrollRectToVisible:(CGRect)aRect animated:(BOOL)animated;
d. 缩放
minimumZoomScale ,maxmumZoomScale 最小最大缩放比例
需实现委托: - (UIView*)viewForZoomingInScrollView:(UIScrollView*)sender;
返回需要缩放的视图;否则缩放无效的。
代码实现:
- (void)setZoomScale:(float)scale animated:(BOOL)animated;
- (void)zoomToRect:(CGRect)zoomRect animated:(BOOL)animated;
e. 各种委托,自己看文档
3. demo
a. 创建ImageViewController,实现imageUrl属性,调用者传url,内部读取到这个url,下载图片,加载显示;
b. 点击不同按钮,调用ImageViewController,传不同url,功能实现,但是卡,并且图片显示不全;
c. 添加ScrollView,实现缩放,可以显示任何大小图片;
d. 实现多线程下载图片,解决卡的问题;
a.得到主队列
dispatch_queue_t main = dispatch_get_main_queue();
or
NSOperationQueue *main = [NSOperationQueue mainQueue];
dispatch_queue_t other = dispatch_queue_create("name", NULL);
- (void)performSelectorOnMainThread:(SEL)aMethod
withObject:(id)obj
waitUntilDone:(BOOL)waitUntilDone;
or
dipatch_async(dispatch_get_main_queue(), ^{ });2. UIScrollView
a. 创建
scrollView.frame = CGRectMake(0,0,300,400);
scrollView.contentSize = CGSizeMake(500,1000);
subView.frame = CGRectMake(0,0,500,1000);
[scrollView addSubview:subView];
[self.view addSubview:scrollView];
b. 当前显示区域
CGPoint point = scrollView.contentOffset;
CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:subView];
c. 滚动到某个区域
- (void)scrollRectToVisible:(CGRect)aRect animated:(BOOL)animated;
d. 缩放
minimumZoomScale ,maxmumZoomScale 最小最大缩放比例
需实现委托: - (UIView*)viewForZoomingInScrollView:(UIScrollView*)sender;
返回需要缩放的视图;否则缩放无效的。
代码实现:
- (void)setZoomScale:(float)scale animated:(BOOL)animated;
- (void)zoomToRect:(CGRect)zoomRect animated:(BOOL)animated;
e. 各种委托,自己看文档
3. demo
a. 创建ImageViewController,实现imageUrl属性,调用者传url,内部读取到这个url,下载图片,加载显示;
b. 点击不同按钮,调用ImageViewController,传不同url,功能实现,但是卡,并且图片显示不全;
c. 添加ScrollView,实现缩放,可以显示任何大小图片;
d. 实现多线程下载图片,解决卡的问题;
e. 添加activityIndicator控件,提高用户体验;