最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS仿微博圖片瀏覽器

 更新時(shí)間:2016年11月29日 09:57:22   作者:LuKane  
這篇文章主要為大家詳細(xì)介紹了iOS仿微博圖片瀏覽器的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

KNPhotoBrower
高仿微博圖片瀏覽器


PhotoBrower.gif

一.功能描述及要點(diǎn)
1.加載網(wǎng)絡(luò)九宮格圖片,collectionView,scrollView
2.SDWebImage下載圖片,KNProgressHUD顯示加載進(jìn)度
3.高仿微博,顯示動畫,KNToast提示

二.方法調(diào)用

1.創(chuàng)建KNPhotoBrower,并傳入相應(yīng)的參數(shù)

// 每一個(gè)圖片控件對象, 對一一對應(yīng) KNPhotoItems ,再將多個(gè)KNPhotoItems 對象放入數(shù)組
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = [urlArr[i] stringByReplacingOccurrencesOfString:@"thumbnail" withString:@"bmiddle"];
items.sourceView = imageView;

KNPhotoBrower *photoBrower = [[KNPhotoBrower alloc] init];
photoBrower.itemsArr = [_itemsArray copy];// KNPhotoItems對象的數(shù)組
photoBrower.currentIndex = tap.view.tag;// 當(dāng)前點(diǎn)擊的哪個(gè)圖片
photoBrower.actionSheetArr = [self.actionSheetArray mutableCopy];//設(shè)置 ActionSheet的選項(xiàng)
[photoBrower present];// 顯示

2.提供代理方法 --> KNPhotoBrowerDelegate

/* PhotoBrower 即將消失 */
- (void)photoBrowerWillDismiss;
/* PhotoBrower 右上角按鈕的點(diǎn)擊 */
- (void)photoBrowerRightOperationActionWithIndex:(NSInteger)index;
/* PhotoBrower 保存圖片是否成功 */
- (void)photoBrowerWriteToSavedPhotosAlbumStatus:(BOOL)success;

3.提供 消失方法
[_photoBrower dismiss];
4.設(shè)置 參數(shù)

/**
 * 是否需要右上角的按鈕. Default is YES;
 */
@property (nonatomic, assign) BOOL isNeedRightTopBtn;
/**
 * 是否需要 頂部 1 / 9 控件 ,Default is YES
 */
@property (nonatomic, assign) BOOL isNeedPageNumView;
/**
 * 是否需要 底部 UIPageControl, Default is NO
 */
@property (nonatomic, assign) BOOL isNeedPageControl;
/**
 * 存放 ActionSheet 彈出框的內(nèi)容 :NSString類型
 */
@property (nonatomic, strong) NSMutableArray *actionSheetArr;

5.關(guān)于彈出框的內(nèi)容,可在KNPhotoBrower.m 的operationBtnIBAction 方法中增減

#pragma mark - 右上角 按鈕的點(diǎn)擊
- (void)operationBtnIBAction{
 __weak typeof(self) weakSelf = self;

 if(_actionSheetArr.count != 0){ // 如果是自定義的 選項(xiàng)

  KNActionSheet *actionSheet = [[KNActionSheet alloc] initWithCancelBtnTitle:nil destructiveButtonTitle:nil otherBtnTitlesArr:[_actionSheetArr copy] actionBlock:^(NSInteger buttonIndex) {

   // 讓代理知道 是哪個(gè)按鈕被點(diǎn)擊了
   if([weakSelf.delegate respondsToSelector:@selector(photoBrowerRightOperationActionWithIndex:)]){
    [weakSelf.delegate photoBrowerRightOperationActionWithIndex:buttonIndex];
   }

#warning 如果傳入的 ActionSheetArr 有下載圖片這一選項(xiàng). 則在這里調(diào)用和下面一樣的方法 switch.....,如果沒有下載圖片,則通過代理方法去實(shí)現(xiàn)... 目前不支持刪除功能

  }];
  [actionSheet show];
 }else{
  KNActionSheet *actionSheet = [[KNActionSheet alloc] initWithCancelBtnTitle:nil destructiveButtonTitle:nil otherBtnTitlesArr:@[@"保存圖片",@"轉(zhuǎn)發(fā)微博",@"贊"] actionBlock:^(NSInteger buttonIndex) {

   // 讓代理知道 是哪個(gè)按鈕被點(diǎn)擊了
   if([weakSelf.delegate respondsToSelector:@selector(photoBrowerRightOperationActionWithIndex:)]){
    [weakSelf.delegate photoBrowerRightOperationActionWithIndex:buttonIndex];
   }

   switch (buttonIndex) {
    case 0:{
     SDWebImageManager *mgr = [SDWebImageManager sharedManager];
     KNPhotoItems *items = _itemsArr[_currentIndex];
     if(![mgr diskImageExistsForURL:[NSURL URLWithString:items.url]]){
      [[KNToast shareToast] initWithText:@"圖片需要下載完成"];
      return ;
     }else{
      UIImage *image = [[mgr imageCache] imageFromDiskCacheForKey:items.url];
      dispatch_async(dispatch_get_main_queue(), ^{
       UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
      });
     }
    }
    default:
     break;
   }
  }];
  [actionSheet show];
 }
}

補(bǔ)充
1.目前適合 九宮格樣式,collectionView,scrollView
2.如果有bug, 請?jiān)贕ithub上通過 '郵箱' 或者 直接issue ,我會盡快修改
github地址:  https://github.com/LuKane/KNPhotoBrower

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

正宁县| 寿宁县| 饶平县| 津南区| 奉贤区| 九台市| 柳河县| 岳西县| 嵊泗县| 岢岚县| 潞西市| 若羌县| 金乡县| 潞西市| 霸州市| 天等县| 林甸县| 宣恩县| 循化| 霸州市| 长丰县| 东丽区| 夏邑县| 阳西县| 牙克石市| 池州市| 广饶县| 板桥市| 托克托县| 左云县| 南阳市| 宁远县| 高唐县| 德州市| 舞阳县| 红桥区| 三亚市| 北辰区| 灵山县| 资溪县| 广宗县|