UICollectionView(相册大图查看)

#import <UIKit/UIKit.h>
#import "BaseViewController.h"
@interface FullAlbumViewController : BaseViewController<UIScrollViewDelegate,UIActionSheetDelegate>
@property (strong, nonatomic) NSArray *assetsArray;
@property (assign, nonatomic) NSInteger currentIndex;
@property (nonatomic,strong)  NSString *path;
@end








#import "FullAlbumViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
#import "FullImageCell.h"
static NSString *cellIdentifier = @"FullImageCell";


@interface FullAlbumViewController ()
<UICollectionViewDataSource, UICollectionViewDelegate>
{

    UILabel * numLb;
    UILabel * desLb;

    int i;
    //
}
@property (strong, nonatomic) UICollectionView *collectionView;


@end

@implementation FullAlbumViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

//    self.automaticallyAdjustsScrollViewInsets = NO;
//    //确定是水平滚动,还是垂直滚动
    UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
    self.collectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH ) collectionViewLayout:flowLayout];
    self.collectionView.dataSource=self;
    self.collectionView.delegate=self;
    self.collectionView.contentOffset = CGPointMake(_currentIndex * kScreenW, 0);
    self.collectionView.pagingEnabled = YES;
    //注册Cell,必须要有
    [self.collectionView registerClass:[FullImageCell class] forCellWithReuseIdentifier:cellIdentifier];
    [self.view addSubview:self.collectionView];

    numLb = [self buildLabelWithFrame:CGRectMake(kScreenW - 150, kScreenH-50,  150, 50) backgroundColor:[UIColor clearColor] textColor:[UIColor whiteColor] font:[UIFont boldSystemFontOfSize:40] textAlignment:NSTextAlignmentRight text:[NSString stringWithFormat:@"%d/%lu",_currentIndex+1,(unsigned long)self.assetsArray.count]];
    [self.view addSubview:numLb];

    desLb = [self buildLabelWithFrame:CGRectMake(0, kScreenH-50, kScreenW - 150, 50) backgroundColor:[UIColor clearColor] textColor:[UIColor whiteColor] font:[UIFont boldSystemFontOfSize:12] textAlignment:NSTextAlignmentLeft text:@""];
    desLb.numberOfLines = 0;
    [self.view addSubview:desLb];

    /*
    self.view.backgroundColor = [UIColor redColor];

    UIScrollView *scrollView =[[ UIScrollView alloc]initWithFrame:self.view.frame];
    scrollView.pagingEnabled = YES;
    scrollView.contentSize = CGSizeMake(kScreenW*self.assetsArray.count, 0);
    scrollView.contentOffset = CGPointMake(kScreenW*_currentIndex, 0);
    scrollView.delegate = self;
    scrollView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:scrollView];


    for (i = 0; i<self.assetsArray.count; i++) {

        scr= [[UIScrollView alloc]initWithFrame:CGRectMake(width(self.view)*i, 0, width(self.view), height(self.view))];

        imageView =[[UIImageView alloc]initWithFrame:scr.frame];
//        imageView.imageURL = [NSURL URLWithString:self.photoArray[i]];
        NSString *ImagePath = [self.path stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png",[self.assetsArray[i] objectForKey:@"imageName"]]];
        imageView.image = [UIImage imageWithContentsOfFile:ImagePath];
        CGFloat imgW = imageView.image.size.width;
        CGFloat imgH = imageView.image.size.height;
        CGFloat imgViewWid ;
        CGFloat imgViewHie; 

        //判断图片实际大小是否大于屏幕尺寸 如果大于则定其宽度等于屏幕宽度 等比缩放图片
        if (imgW>kScreenW) {
            imgViewWid = kScreenW;
            imgViewHie = kScreenW * imgH/imgW;
        }else{
            imgViewWid = imgW;
            imgViewHie = imgH;
        }
        imageView.frame = CGRectMake(0, 0, imgViewWid, imgViewHie);
        imageView.userInteractionEnabled = YES;
        imageView.center = CGPointMake(kScreenW/2, kScreenH/2);
        imageView.tag = 1000+i;


        [scr addSubview:imageView];

        [scr addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backView)]];
        scr.backgroundColor = [UIColor blackColor];
        [scrollView addSubview:scr];



        numLb = [self buildLabelWithFrame:CGRectMake(width(self.view)-170, height(self.view)-100, 150, 100) backgroundColor:[UIColor clearColor] textColor:[UIColor whiteColor] font:[UIFont boldSystemFontOfSize:40] textAlignment:NSTextAlignmentRight text:[NSString stringWithFormat:@"%d/%lu",_currentIndex+1,(unsigned long)self.assetsArray.count]];
        [self.view addSubview:numLb];



    }
*/

}



-(void)backView
{
//    [self.menuController popViewControllerAnimated:NO];

    //     [self.menuController pushViewController:nav withTransitionAnimator:[MDTransitionAnimatorFactory transitionAnimatorWithType:MDAnimationTypeSlideFromRight]];
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
//    numLb.text = @"";
    int num = self.collectionView.contentOffset.x/width(self.view);
    int allnum = self.collectionView.contentSize.width/width(self.view);
    numLb.text = [NSString stringWithFormat:@"%d/%d",num+1,allnum];
    desLb.text = [self.assetsArray[num] objectForKey:@"Location"];
//    saveButton.tag = num;
        NSLog(@"----------%d",num);
}




#pragma mark - <UICollectionViewDataSource>
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return [UIScreen mainScreen].bounds.size;
}


- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 0.0f;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 0.0f;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.assetsArray.count;
}

- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    FullImageCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    NSString *ImagePath = [self.path stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png",[self.assetsArray[indexPath.row] objectForKey:@"imageName"]]];
    cell.albumView.image = [UIImage imageWithContentsOfFile:ImagePath];
    CGFloat imgW = cell.albumView.image.size.width;
    CGFloat imgH = cell.albumView.image.size.height;
    CGFloat imgViewWid ;
    CGFloat imgViewHie;
    //判断图片实际大小是否大于屏幕尺寸 如果大于则定其宽度等于屏幕宽度 等比缩放图片
    if (imgW>kScreenW) {
        imgViewWid = kScreenW;
        imgViewHie = kScreenW * imgH/imgW;
    }else{
        imgViewWid = imgW;
        imgViewHie = imgH;
    }
    cell.albumView.frame = CGRectMake(0, 0, imgViewWid, imgViewHie);
    cell.albumView.userInteractionEnabled = YES;
    cell.albumView.center = CGPointMake(kScreenW/2, kScreenH/2);
    desLb.text = [self.assetsArray[indexPath.row] objectForKey:@"Location"];
    return cell;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (self.navigationController.navigationBarHidden) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
        self.navigationController.navigationBarHidden = NO;
    }
    else {
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
        self.navigationController.navigationBarHidden = YES;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
彻底卸载Windows Defender,您可以按照以下步骤进行操作: 1. 打开计算机的设置菜单。在Windows 10中,您可以通过点击开始按钮,然后选择“设置”图标进入设置菜单。在较早的Windows版本中,可以在控制面板中找到设置选项。 2. 在设置菜单中,选择“应用”或“应用和功能”选项。 3. 在应用列表中,向下滚动并找到“Windows Defender Security Center”或“Windows Defender”应用。点击它。 4. 在新打开的应用页面中,您将看到卸载选项。点击“卸载”按钮。 5. 系统将要求确认您的操作。点击“是”继续。 6. 系统会开始卸载Windows Defender应用。请耐心等待直至完成。 7. 完成后,您可以关闭设置窗口。 尽管如此,在Windows 10中,无法完全卸载Windows Defender的所有组件,因为它是操作系统的一部分,并且为了保护计算机安全而设计。您可以选择禁用Windows Defender以停止其运行,而不是进行完全卸载。要禁用Windows Defender,请按照以下步骤操作: 1. 打开计算机的设置菜单,如上所述。 2. 在设置菜单中,选择“更新和安全”选项。 3. 在左侧导航栏中,选择“Windows Security”选项。 4. 在新打开的窗口中,选择“病毒和威胁防护”选项。 5. 在“病毒和威胁防护设置”下,点击“管理设置”链接。 6. 将“实时保护”开关设置为关闭状态。 通过以上步骤,您可以禁用Windows Defender,以便使用其他的防病毒软件或满足其他需求。请注意,禁用Windows Defender可能会使您的计算机面临安全风险,因此建议您安装另一个可靠的防病毒软件以保护计算机。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值