-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForumViewSSController.m
73 lines (59 loc) · 2.3 KB
/
ForumViewSSController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// ForumViewSSController.m
// new_LinearAlgebra
//
// Created by WorkSpace_付国强 on 15/1/22.
// Copyright (c) 2015年 付国强. All rights reserved.
//
#import "ForumViewSSController.h"
#import "ConstantHeader.h"
@implementation ForumViewSSController{
UIWebView *webView;
NSURLRequest *request;
}
- (instancetype)init
{
self = [super init];
if (self) {
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, MAIN_SCREEN_X, MAIN_SCREEN_Y)];
webView.delegate = self;
self.title = @"在线交流";
}
return self;
}
-(void)viewDidLoad{
[super viewDidLoad];
[self.view addSubview:webView];
UISwipeGestureRecognizer *gesture_left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(moveWebView:)];
gesture_left.direction = UISwipeGestureRecognizerDirectionLeft;
[webView addGestureRecognizer:gesture_left];
UISwipeGestureRecognizer *gesture_right = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(moveWebView:)];
gesture_right.direction = UISwipeGestureRecognizerDirectionLeft;
[webView addGestureRecognizer:gesture_right];
request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxdsapp.710071.net/luntan/forum.php"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
[webView loadRequest:request];
}
#pragma mark--
#pragma webView delegate
-(void)webViewDidStartLoad:(UIWebView *)webView{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
message:@"加载失败,稍后重试"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
- (void)moveWebView:(UISwipeGestureRecognizer *)gesture {
if(gesture.direction == UISwipeGestureRecognizerDirectionLeft) {
[webView goBack];
}else {
[webView goForward];
}
}
@end