照片浏览scrollview and pageCotrol
来源:互联网 发布:线程私有数据意义 编辑:程序博客网 时间:2024/05/29 07:09
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UIScrollViewDelegate>
{
NSMutableArray *_mutArrImg;
UIPageControl *_pageControl;
UIScrollView *_scrollView;
}
@property (strong, nonatomic) UIWindow *window;
@end
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
_scrollView = [[UIScrollView alloc] initWithFrame:self.window.bounds];
[self.window addSubview:_scrollView];
_scrollView.delegate = self;
_scrollView.contentSize = CGSizeMake(320*4, self.window.frame.size.height);
_scrollView.pagingEnabled = YES;
_mutArrImg = [NSMutableArray arrayWithCapacity:0];
for (int i=0; i<4; i++) {
NSURL *url = [NSURL URLWithString:@"http://pica.nipic.com/2007-12-12/20071212235955316_2.jpg"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *imgData = [NSData dataWithContentsOfURL:url];
UIImage *img = [UIImage imageWithData:imgData];
dispatch_sync(dispatch_get_main_queue(), ^{
[_mutArrImg addObject:img];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(320*i, 0, 320, self.window.frame.size.height)];
imgView.image = img;
[_scrollView addSubview:imgView];
});
});
}
_pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 400, 320, 30)];
_pageControl.numberOfPages = 4;
_pageControl.currentPage = 0;
_pageControl.pageIndicatorTintColor = [UIColor redColor];
[self.window addSubview:_pageControl];
[_pageControl addTarget:self action:@selector(actionCotrolPage:) forControlEvents:UIControlEventValueChanged];
[self.window makeKeyAndVisible];
return YES;
}
- (IBAction)actionCotrolPage:(id)sender
{
[_scrollView setContentOffset:CGPointMake(_pageControl.currentPage * 320, 0) animated:YES];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
_pageControl.currentPage = _scrollView.contentOffset.x/320;
}
0 0
- 照片浏览scrollview and pageCotrol
- 照片浏览
- 照片浏览模式
- 图片浏览的ScrollView
- 简单的照片查看浏览
- cookie---照片浏览历史显示
- 照片预览的scrollView控件
- 【iOS开发】---- 照片多张浏览
- C# winform 照片浏览小程序
- iOS swift-UICollectionView实现照片浏览
- Android 横向ScrollView照片浏览器实现
- ScrollView and pageControl
- TableView and ScrollView
- scrollview and scrollbar
- 手机拍照,浏览手机的文件夹,上传照片到服务器
- jQuery+PHP+Mysql在线拍照和在线浏览照片
- 照片浏览滑动效果UIScrollView和UIPageControl组合
- Cooliris – 优雅的照片浏览工具[iOS/Android]
- 区域卫生信息平台唱响医疗信息化主旋律
- xna开发资源收集
- C\C++变量命名规范
- 我的extjs聊天机器人
- cocos2dx之CCGLProgram着色器类
- 照片浏览scrollview and pageCotrol
- android View 保存成Bitmap对象
- Linux下的一个全新的性能测量和调试诊断工具Systemtap【3】System
- Java之美[从菜鸟到高手演变]之Exception .
- Cocos2d-x设计模式之四 :外观模式
- PHP导入导出Excel方法小结
- Ruby中“||=”符号
- 啊是发顺丰的规范
- WCF开发教程资源收集