我正试着在UIViewController上做一个UIWebview。我想要的网页视图只出现在网站已加载。然后,UIWebView将从屏幕底部移动到半个屏幕。
我是iOS上的动画新手。我可以知道我怎么能做到这一点吗?
目前,我只能在加载网站时获得网页视图...
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *fullURL = @"http://www.google.com"; NSURL *url = [NSURL URLWithString:fullURL]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj];
}
发布于 2012-03-18 16:21:50
在您拥有的viewDidLoad:方法中,添加以下行:
webView.hidden = YES;
webView.delegate = self; // also remember to say you implement UIWebViewDelegate in the .h file
然后实现webViewDidFinishLoad: delegate方法,在其中插入类似以下内容的内容:
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);
}];
发布于 2012-03-18 16:09:48
一种替代方法是使用以下内容:
- viewDidLoad
中的URLRequest
方法放在后台进程中(这样它就不会阻塞UI)<代码>G211
5.加载后,调用该方法将webView推入可见视图。例如:
pushWebView:@“Pop WebView”上下文:nil;UIView beginAnimations UIView setAnimationDuration:0.5;self.webView setFrame:;//或者使用CGAffineTransform UIView commitAnimations;nil
https://stackoverflow.com/questions/9759596
复制