在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);
}];
答
一个替代方案是用如下:
声明的UIWebView的一个实例(@财产和@synthesize)
把它挂在IB
在
- viewDidLoad
设置其帧送出侧的视图(因此它不能看到)把你
URLRequest
方法在后台进程(因此它不会阻止用户界面)
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/