#import
//@protocol FullImgViewControllerDelegate<NSObject>
//- (void)tapClick;
//@end
@interface FullImgViewController : UIViewController
@property (nonatomic,strong) NSArray *urlArr;
@property (nonatomic,strong) NSArray *imageArr;
//第幾張
@property (nonatomic,assign) NSInteger btnTag;
@property (weak, nonatomic) IBOutlet UIButton *lookDetailBtn;
@property (nonatomic,strong) NSString *pid;//作品id
@property (nonatomic,assign) NSInteger comeFrom;//2017.2.27 從幫我搭配過來給 1 原來的放else
//@property (nonatomic,strong) id<FullImgViewControllerDelegate>delegate;
@end
#import "UIImage+Image.h" //根據(jù)顏色生成圖片
#import "ImageShowCell.h"
#define IMAGESHOWCELL @"ImageShowCell"
#define GRAYCOLOR2 [UIColor lightGrayColor]
@interface FullImgViewController ()<ImageShowCellDelegate>
{
? ? __weakIBOutletUILabel*mNumLabel;
? ? __weakIBOutletUICollectionView*mCollection;
? ? NSMutableArray*mUrlArr;
? ? NSIntegerimageNum;
}
@end
@implementation FullImgViewController
- (void)viewWillAppear:(BOOL)animated {
? ? [superviewWillAppear:animated];
? ? [self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? if(![self.pidisEqualToString:@""]) {
? ? ? ? self.lookDetailBtn.hidden=NO;
? ? }
? ? mUrlArr = [[NSMutableArray alloc]init];
? ? if(self.urlArr.count>0) {
? ? ? ? [mUrlArr addObjectsFromArray:self.urlArr];
? ? }
? ? else{
? ? ? ? [mUrlArr addObjectsFromArray:self.imageArr];
? ? }
? ? mNumLabel.text = [NSString stringWithFormat:@"%ld/%lu",(long)self.btnTag,(unsigned long)mUrlArr.count];
//? ? self.navigationController.navigationBar.hidden = YES;
? ? mCollection.backgroundColor = [UIColor blackColor];
? ? self.view.backgroundColor = [UIColor blackColor];
? ? [mCollection registerNib:[UINib nibWithNibName:IMAGESHOWCELL bundle:nil] forCellWithReuseIdentifier:IMAGESHOWCELL];
? ? mCollection.contentSize = CGSizeMake(SCREEN_WIDTH*mUrlArr.count, SCREEN_HEIGHT);
? ? mCollection.contentOffset = CGPointMake(SCREEN_WIDTH *(self.btnTag-1), 0);
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
? ? if(@available(iOS13.0, *)) {
? ? ? ? return UIStatusBarStyleDarkContent;
? ? }else{
? ? ? ? return UIStatusBarStyleDefault;
? ? }
? ? //UIStatusBarStyleDefault = 0 黑色文字,淺色背景時使用
? ? //UIStatusBarStyleLightContent = 1 白色文字胯杭,深色背景時使用
}
- (BOOL)prefersStatusBarHidden
{
? ? return YES; // 返回NO表示要顯示忌卤,返回YES將hiden
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
? ? returnmUrlArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
? ? ImageShowCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:IMAGESHOWCELL forIndexPath:indexPath];
? ? cell.delegate=self;
? ? cell.contentView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
? ? if ([mUrlArr[indexPath.row] isKindOfClass:[NSString class]]) {
? ? ? ? NSString*urlStr =mUrlArr[indexPath.row];
? ? ? ? NSURL*url;
? ? ? ? cell.progressLabel.hidden=YES;
? ? ? ? url = [NSURLURLWithString:urlStr];//2019.11.8
? ? ? ? [cell.imgView sd_setImageWithURL:url];
//? ? ? ? [cell.imgView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""] options:SDWebImageAllowInvalidSSLCertificates progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
//? ? ? ? ? ? dispatch_async(dispatch_get_main_queue(), ^{
//? ? ? ? ? ? ? ? int pro = (int)((float)receivedSize/(float)expectedSize*100);
//? ? ? ? ? ? ? ? if (pro>0) {
//
//? ? ? ? ? ? ? ? }
//? ? ? ? ? ? ? ? else{
//? ? ? ? ? ? ? ? ? ? pro = 0;
//? ? ? ? ? ? ? ? }
//? ? ? ? ? ? ? ? cell.progressLabel.text = [NSString stringWithFormat:@"%d%@",pro,@"%"];
//? ? ? ? ? ? });
//? ? ? ? } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
//? ? ? ? ? ? dispatch_async(dispatch_get_main_queue(), ^{
//? ? ? ? ? ? ? ? cell.progressLabel.hidden = YES;
//? ? ? ? ? ? });
//
//? ? ? ? }];
? ? }
? ? else{
? ? ? ? cell.progressLabel.hidden=YES;
? ? ? ? cell.imgView.image=mUrlArr[indexPath.row];
? ? }
? ? returncell;
}
- (void)tapClick{
//? ? [self.delegate tapClick];
? ? [self.navigationController popViewControllerAnimated:NO];
}
//定義每個UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView*)collectionViewlayout:(UICollectionViewLayout*)collectionViewLayoutsizeForItemAtIndexPath:(NSIndexPath*)indexPath
{
? ? return CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
}
-(UIEdgeInsets)collectionView:(UICollectionView*)collectionViewlayout:(UICollectionViewLayout*)collectionViewLayoutinsetForSectionAtIndex:(NSInteger)section
{
? ? return UIEdgeInsetsMake(0, 0, 0, 0);
}
- (void)scrollViewDidScroll:(UIScrollView*)scrollView{
? ? NSInteger num = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
? ? NSLog(@"第%ld",(long)num);
? ? imageNum= num+1;
? ? mNumLabel.text = [NSString stringWithFormat:@"%ld/%lu",(long)imageNum,(unsigned long)mUrlArr.count];
}
- (IBAction)lookDetailClick:(id)sender {
}
- (void)didReceiveMemoryWarning {
? ? [super didReceiveMemoryWarning];
}