iOS Collection滚动显示图像
来源:互联网 发布:淘宝职称论文署名单位 编辑:程序博客网 时间:2024/06/04 15:54
//
// ViewController.m
// 070402连续显示图片
//
// Created by tianshangrenjian on 15/7/4.
// Copyright © 2015年 tianshangrenjian. All rights reserved.
//
#define SCHCELL @"cell"
#import "ViewController.h"
@interface ViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutletUIScrollView *schScroll;
@property (strong ,nonatomic)NSMutableArray *pics;
@property (weak, nonatomic) IBOutletUICollectionView *schCollection;
@end
@implementation ViewController
- (NSMutableArray *)pics
{
if (_pics==nil) {
_pics=[NSMutableArrayarray];
}
return _pics;
}
- (NSInteger)collectionView:(nonnullUICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
NSLog(@"cao");
return 9;
}
- (UICollectionViewCell*)collectionView:(nonnullUICollectionView *)collectionView cellForItemAtIndexPath:(nonnullNSIndexPath *)indexPath
{
UICollectionViewCell *cell=[collectionViewdequeueReusableCellWithReuseIdentifier:SCHCELLforIndexPath:indexPath];
NSString *path=[NSStringstringWithFormat:@"%zd.jpg",indexPath.row+1];
NSLog(@"%@",path);
UIImageView *view=[[UIImageViewalloc] initWithImage:[UIImageimageNamed:path]];
view.contentMode=UIViewContentModeScaleToFill;
view.contentScaleFactor=0;
// view.frame=self.schCollection.bounds;
view.frame=cell.bounds;
[celladdSubview:view];
return cell;
}
-(void)showPic
{
CGFloat x=0;
CGFloat width=self.schScroll.bounds.size.width;
CGFloat height=self.schScroll.bounds.size.height;
for (int i=1; i<10; i++) {
UIImage *img=[UIImageimageNamed:[NSStringstringWithFormat:@"%d.jpg",i]];
UIImageView *imgView=[[UIImageViewalloc] initWithImage:img];
imgView.frame=CGRectMake(x,0, width, height);
x+=width;
[self.schScrolladdSubview:imgView];
}
self.schScroll.contentSize=CGSizeMake(9*width, height);
// self.schScroll.frame=CGRectMake(0, 0, imgView.frame.size.width*self.pics.count, imgView.frame.size.height);
// [self.schScroll addSubview:imgView];
}
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.schCollection.delegate=self;
self.schCollection.dataSource=self;
[self.schCollectionregisterClass:[UICollectionViewCellclass] forCellWithReuseIdentifier:SCHCELL];
[selfshowPic];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- iOS Collection滚动显示图像
- ios UIScrollView 创建多图像分页滚动
- iOS-圆形图像显示(UIImageView)
- iOS走马灯上下滚动显示文本
- IOS 上YUV图像显示相关参考
- iOS中显示WEBP动态图像
- 滚动显示
- 【IOS】仿捕鱼达人的金币滚动显示
- 【IOS】仿捕鱼达人的金币滚动显示
- 【IOS】仿捕鱼达人的金币滚动显示
- iOS 实现webview不滚动,显示所有内容
- iOS 类似股票数据显示的可上下左右滚动TableView
- ios 页面向上滚动显示toolbar/searchBar 页面向下滚动隐藏toolbar/searchBar
- iOS开发UIScrollView一直显示滚动条,滚动条的一些属性
- iOS code collection
- iOS OpenSource Library Collection
- iOS Collection 集合
- iOS OC Sugars collection
- Linux学习笔记(九)——Linux文件压缩与打包
- python写的一个邮件收发工具
- 黑马程序员——函数
- POSIX线程-互斥量
- ubuntu下使用NDK 生成so库文件时MK文件的编写
- iOS Collection滚动显示图像
- [华为机试练习题]53.整数相除(AC 但还有bug)
- hdu1176(dp)
- posix线程-线程的取消
- RelativeLayout里的gravity不能居中的解决方法
- POSIX线程-Per-Thread Storage
- MooseFS代码分析(一)
- initializer element is not constant 问题
- js阻止事件默认行为