列出幾個常用到的地方
UIAlertView
#import <UIControl+BlocksKit.h>
UIAlertView *alertView = [[UIAlertView alloc] bk_initWithTitle:@"系統訊息" message:@"有新版本可供下載,請即刻更新!!"];
[alertView bk_addButtonWithTitle:@"升級" handler:^{
//...
}];
[alertView show];
UIButton
__weak __typeof__(self) weakSelf = self;
if ([btnForRemove bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside]) {
[btnForRemove bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
}
[btnForRemove bk_addEventHandler:^(id sender) {
__strong __typeof__(weakSelf) self = weakSelf;
AlertForMyCollectsViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"AlertForMyCollectsViewControllerID"];
vc.delegate = self;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
[self presentViewController:vc animated:YES completion:nil];
}
else {
// Fixed transparent vc is not working in iOS7
vc.transitioningDelegate = self;
vc.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:vc animated:YES completion:nil];
}
} forControlEvents:UIControlEventTouchUpInside];
UIWebView
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_item.itemUrl]]];
[self.webView bk_setShouldStartLoadBlock:^BOOL(UIWebView *webView, NSURLRequest *request, UIWebViewNavigationType navigationType) {
NSString *buf = [[request URL] relativePath];
if ([buf rangeOfString:@"water-video.html"].location != NSNotFound) {
//...
}
return YES;
}];