在UIViewController上动画UIWebView

问题描述:

我想在UIViewController上制作一个UIWebview。我希望Web视图仅在网站加载后才显示。然后,UIWebView将从屏幕底部移动到屏幕的一半。在UIViewController上动画UIWebView

我是iOS新手。我可以知道我该怎么做?

此刻,我只能得到Web视图加载网站...

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    NSString *fullURL = @"http://www.google.com"; NSURL *url = [NSURL URLWithString:fullURL]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; 
} 

在viewDidLoad中:你有没有方法,添加这些行:

webView.hidden = YES; 
webView.delegate = self; // also remember to say you implement UIWebViewDelegate in the .h file 

然后实现webViewDidFinishLoad:委托方法,您插入类似以下内容:

webView.frame = CGRectMake(someX, self.view.frame.size.height, someWidth, someHeight); 
webView.hidden = NO; 
[UIView animateWithDuration:1.0 animations:^{ 
    webView.frame = CGRectMake(someX, self.view.frame.size.height/2, someWidth, someHeight); 
}]; 

一个替代方案是用如下:

  1. 声明的UIWebView的一个实例(@财产和@synthesize)

  2. 把它挂在IB

  3. - viewDidLoad设置其帧送出侧的视图(因此它不能看到)

  4. 把你URLRequest方法在后台进程(因此它不会阻止用户界面)

4.1 。这里是教程http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial

5.一旦它被加载调用方法将webView推入可见视图。例如

- (void) pushWebView { 
    [UIView beginAnimations:@"Pop WebView" context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.5]; 
    [self.webView setFrame:<frame>]; // or use CGAffineTransform 
    [UIView commitAnimations]; 
} 

5.1。这里是教程为http://www.idev101.com/code/User_Interface/UIView/