- (id)initWithURL:(NSString *)string{ self=[super init];if(self) url=string; return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. page=[[UIWebView alloc]initWithFrame:self.view.bounds];page.scalesPageToFit=YES;page.delegate=self;[self.view addSubview:page]; toolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-36, self.view.frame.size.width,36)]; toolbar.tintColor=[UIColor blackColor];toolbar.translucent=YES; [self.view addSubview:toolbar]; back=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(back)]; forward=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(forward)]; done=[[UIBarButtonItem alloc]initWithTitle:@"done" style:UIBarButtonItemStyleDone target:self action:@selector(killme)]; NSArray *buttons=[[NSArray alloc]initWithObjects:done,back,forward,nil]; [toolbar setItems:buttons animated:YES]; [page loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; } - (void)webViewDidStartLoad:(UIWebView *)webView{ if(!ai) ai=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [ai setCenter:self.view.center];[self.view addSubview:ai];[ai startAnimating]; [self update]; } - (void)webViewDidFinishLoad:(UIWebView *)webView{ if(ai) [ai removeFromSuperview]; [self update]; } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ //nothing. } - (void)update{ back.enabled=page.canGoBack; forward.enabled=page.canGoForward; } - (void)killme{[self.view removeFromSuperview];} - (void)back{if(page.canGoBack)[page goBack];} - (void)forward{if(page.canGoForward)[page goForward];}
できた。まあこのへんは参考にできる文書が山のようにあるので楽チン。残すはchat、audio、videoか。なんとかなるかな。
昼は3738@長居で特製中華そば。ガラガラ。思ってたよりは美味しかった。今月まだ10杯目。
0 件のコメント:
コメントを投稿