//
|
// MJWebViewViewController.m
|
// BaseProject
|
//
|
// Created by WindShan on 2016/12/7.
|
// Copyright © 2016年 WindShan. All rights reserved.
|
//
|
|
#import "MJWebViewViewController.h"
|
|
|
#define MJPerformSelectorLeakWarning(Stuff) \
|
do { \
|
_Pragma("clang diagnostic push") \
|
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
|
Stuff; \
|
_Pragma("clang diagnostic pop") \
|
} while (0)
|
|
@interface MJWebViewViewController ()<UIWebViewDelegate>
|
@property (strong, nonatomic) UIWebView *_webView;
|
|
@end
|
|
@implementation MJWebViewViewController
|
|
#pragma mark - 示例
|
- (void)example31
|
{
|
|
|
|
// 如果是上拉刷新,就以此类推
|
}
|
|
#pragma mark - webViewDelegate
|
- (void)webViewDidFinishLoad:(nonnull UIWebView *)webView
|
{
|
[self._webView.scrollView.mj_header endRefreshing];
|
}
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
|
self._webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
|
|
// 加载页面
|
[self._webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://weibo.com/exceptions"]]];
|
|
self._webView.delegate = self;
|
|
[self.view addSubview:self._webView];
|
|
[self setMethod:self.title];
|
|
// 添加下拉刷新控件
|
self._webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^
|
{
|
[self._webView reload];
|
}];
|
|
// self._webView.scrollView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
|
// [self._webView reload];
|
// }];
|
|
// 根据方法名字调用该方法
|
MJPerformSelectorLeakWarning(
|
[self performSelector:NSSelectorFromString(self.method) withObject:nil];
|
);
|
// Do any additional setup after loading the view.
|
}
|
|
static char MethodKey;
|
- (void)setMethod:(NSString *)method
|
{
|
objc_setAssociatedObject(self, &MethodKey, method, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
}
|
|
- (NSString *)method
|
{
|
return objc_getAssociatedObject(self, &MethodKey);
|
}
|
|
- (void)didReceiveMemoryWarning {
|
[super didReceiveMemoryWarning];
|
// Dispose of any resources that can be recreated.
|
}
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
{
|
[super viewWillAppear:animated];
|
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
|
[self setNeedsStatusBarAppearanceUpdate];
|
}
|
|
- (void)viewWillDisappear:(BOOL)animated
|
{
|
[super viewWillDisappear:animated];
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
}
|
|
- (BOOL)prefersStatusBarHidden
|
{
|
return YES;
|
}
|
|
/*
|
#pragma mark - Navigation
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
// Get the new view controller using [segue destinationViewController].
|
// Pass the selected object to the new view controller.
|
}
|
*/
|
|
@end
|