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.