-
Notifications
You must be signed in to change notification settings - Fork 106
/
SNReadMeViewController.m
55 lines (44 loc) · 1.89 KB
/
SNReadMeViewController.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
#import "SNReadMeViewController.h"
@implementation SNReadMeViewController
@synthesize myWebView;
@synthesize fake;
- (void)dealloc
{
[myWebView release];
myWebView = nil;
[fake release];
fake = nil;
[super dealloc];
}
- (instancetype)init
{
if ((self = [super init]))
{
self.navigationItem.title = NSLocalizedString(@"Readme", @"Readme");
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Huh?", @"Huh?") style:UIBarButtonItemStylePlain target:self action:@selector(kidding)] autorelease];
myWebView = [[UIWebView alloc] init];
}
return self;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[myWebView.scrollView setContentSize:CGSizeMake(myWebView.frame.size.width, myWebView.scrollView.contentSize.height)];
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
NSString *filePath = nil;
filePath = [self.fake boolValue] ? [[NSBundle mainBundle] pathForResource:[language stringByAppendingString:@"_fake"] ofType:@"html"] : [[NSBundle mainBundle] pathForResource:language ofType:@"html"];
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) filePath = [self.fake boolValue] ? [[NSBundle mainBundle] pathForResource:@"en_fake" ofType:@"html"] : [[NSBundle mainBundle] pathForResource:@"en" ofType:@"html"];
myWebView.delegate = self;
self.view = myWebView;
[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
}
- (void)kidding
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:NSLocalizedString(@"Hope is a good thing, maybe the best of things. And no good thing ever dies.", @"Hope is a good thing, maybe the best of things. And no good thing ever dies.") delegate:self cancelButtonTitle:NSLocalizedString(@"You idiot!", @"You idiot!") otherButtonTitles:nil];
[alertView show];
[alertView release];
}
@end