IOS Imitation micro-blog Image browser _ios

Source: Internet
Author: User

Knphotobrower
High Imitation micro-blog Image browser


Photobrower.gif

I. Functional description and key points
1. Load Network Nine Sudoku pictures, Collectionview,scrollview
2.SDWebImage download picture, Knprogresshud Show loading progress
3. High Imitation micro-blog, display animation, kntoast tips

Two. Method call

1. Create the Knphotobrower and pass in the corresponding parameters

Each image control object, to one by one corresponding Knphotoitems, and then put multiple Knphotoitems objects into the array
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 Object array
photobrower.currentindex = tap.view.tag;// Which picture is currently clicked
Photobrower.actionsheetarr = [Self.actionsheetarray mutablecopy];//set actionsheet options
[ Photobrower present];//Display

2. Provide proxy method--> Knphotobrowerdelegate

/* Photobrower is about to disappear * *
-(void) Photobrowerwilldismiss;
/* Photobrower button on the upper right corner of the Click/
-(void) Photobrowerrightoperationactionwithindex: (nsinteger) index;
/* Photobrower Save the picture is successful/
-(void) Photobrowerwritetosavedphotosalbumstatus: (BOOL) success;

3. Provide vanishing method
[_photobrower dismiss];
4. Set parameters

/**
 * Whether you need a button in the upper-right corner. Default is YES;
 * *
@property (nonatomic, assign) BOOL isneedrighttopbtn;
/**
 * Requires top 1/9 controls, Default is YES
 * * *
@property (nonatomic, assign) BOOL Isneedpagenumview;
/**
 * Whether the bottom uipagecontrol is required, the Default is NO *
 *
@property (nonatomic, assign) BOOL Isneedpagecontrol;
/**
 * Contents of actionsheet pop-up box: nsstring type * * *
@property (nonatomic, strong) Nsmutablearray *actionsheetarr ;

5. The contents of the pop-up box can be added or subtracted in the knphotobrower.m Operationbtnibaction method

#pragma mark-click on the top right button-(void) operationbtnibaction{__weak typeof (self) weakself = self; if (_actionsheetarr.count!= 0) {//If it is a customized option knactionsheet *actionsheet = [[Knactionsheet alloc] Initwithcancelbtntitl E:nil destructivebuttontitle:nil Otherbtntitlesarr:[_actionsheetarr Copy] actionblock:^ (NSInteger buttonIndex) {//Let generation The manager knows which button was clicked if ([Weakself.delegate respondstoselector: @selector (photobrowerrightoperationactionwithindex:)]) {[We
   Akself.delegate Photobrowerrightoperationactionwithindex:buttonindex]; #warning If the incoming Actionsheetarr has the option to download the picture. Then the same method as the following is invoked to switch ... if no pictures are downloaded, then the proxy method is implemented ...
  Delete feature is not currently supported}];
 [Actionsheet show]; }else{Knactionsheet *actionsheet = [[Knactionsheet alloc] Initwithcancelbtntitle:nil destructivebuttontitle:nil otherbtntitlesarr:@[@ "Save Picture" @ "forward Weibo" @ "Praise"] actionblock:^ (Nsinteger buttonindex) {//Let the agent know which button was clicked if ([Weakself.de Legate 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:@ "picture needs to be downloaded"];
     return;
      }else{uiimage *image = [[Mgr Imagecache] imageFromDiskCacheForKey:items.url]; Dispatch_async (Dispatch_get_main_queue (), ^{uiimagewritetosavedphotosalbum (image, Self, @selector (image:didfinish
      Savingwitherror:contextinfo:), NULL);
     });
   }} Default:break;
  }
  }];
 [Actionsheet show];

 }
}

Add
1. Currently suitable for nine Sudoku style, Collectionview,scrollview
2. If there is a bug, please github through the ' mailbox ' or direct issue, I will revise as soon as possible
GitHub Address: Https://github.com/LuKane/KNPhotoBrower

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.