-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeroViewController.m
More file actions
111 lines (84 loc) · 3.26 KB
/
HeroViewController.m
File metadata and controls
111 lines (84 loc) · 3.26 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// DescriptionViewController.m
// sanguocai
//
// Created by Li Wen Jun on 13-11-24.
// Copyright (c) 2013年 Li Wen Jun. All rights reserved.
//
#import "HeroViewController.h"
@interface HeroViewController ()
@end
@implementation HeroViewController
@synthesize bt;
@synthesize heroTxt;
@synthesize webView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.textView = [[UITextView alloc] initWithFrame:CGRectMake(0,50,320,380)]; //初始化大小并自动释放
self.textView.textColor = [UIColor blackColor];//设置textview里面的字体颜色
self.textView.font = [UIFont fontWithName:@"Arial" size:18.0];//设置字体名字和字体大小
self.textView.delegate = self;//设置它的委托方法
self.textView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
printf( "Family: %s \n", [familyName UTF8String] );
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames ){
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}
self.textView.text = self.heroTxt;
//设置它显示的内容
self.textView.returnKeyType = UIReturnKeyDefault;//返回键的类型
self.textView.keyboardType = UIKeyboardTypeDefault;//键盘类型
self.textView.scrollEnabled = YES;//是否可以拖动
[self.textView setEditable:NO];
self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
[self.view addSubview: self.textView];//加入到整个页面中
CGRect rect = [ UIScreen mainScreen ].applicationFrame;
CGSize size = rect.size;
// CGFloat width = size.width;
// CGFloat height = size.height;
int heightFour = size.height;
if (heightFour>480) {
CGRect frame = bt.frame;
frame.origin.y = 517;
bt.frame = frame;
}
int leng = [self.heroTxt length];
if (leng < 10) {
[self.textView setHidden:YES];
NSString *ur = [NSString stringWithFormat:@"http://wapbaike.baidu.com"];
if (heightFour>480) {
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, 320, 468)];
}
else{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, 320, 380)];
}
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:ur]];
[self.view addSubview: webView];
[webView loadRequest:request];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction) backGame{
// DeviceViewController *gameView = [[DeviceViewController alloc]init];
// [self removeFromParentViewController];
// [self presentModalViewController:gameView animated:YES];
[self dismissModalViewControllerAnimated:YES];
}
@end