在 modalViewController iphone 上添加 ActivityIndicator
我正在尝试在 modalViewController 上添加 ActivityIndicator。
基本上我想在用户按下此 modalViewController 上的按钮后开始为该 ActivityIndicator 制作动画。但是发生的事情是,在这个 modalViewController 上触发presentModalViewController之前我所做的一切都保持不变,即如果我只是添加activityIndicator并在呈现modalView之后,那么即使我启动它它也不会显示。但是如果在预设这个 modalViewController 之前如果我触发 [activity startAnimating];然后在呈现 modalView 活动后显示动画。
所以基本上,我想简单地在 modalViewController 上添加 ActivityIndicator 并在按下按钮后开始为其设置动画。
我正在使用以下代码:
imageUploadView = [[UIViewController alloc]initWithNibName:nil bundle:nil];
CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0);
loading = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[loading sizeToFit];
loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[imageUploadView.view addSubview:loading];
[_picker_ presentModalViewController:imageUploadView animated:YES];
有人可以帮忙吗?
提前致谢。
I'm trying to add an activityIndicator on a modalViewController.
Basically I want to start animating this activityIndicator after user presses a button on this modalViewController. But what's happening is whatever I'm doing before firing presentModalViewController on this modalViewController is staying constant i.e. If I simply add activityIndicator and after presenting modalView, then even if I start it it doesn't show up. But if Before preseting this modalViewController if I fire [activity startAnimating]; then after presenting the modalView activity shows up animating.
So basically, I want to simply add the activityIndicator on modalViewController and start animating it after I press a button.
I'm using the following code:
imageUploadView = [[UIViewController alloc]initWithNibName:nil bundle:nil];
CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0);
loading = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[loading sizeToFit];
loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[imageUploadView.view addSubview:loading];
[_picker_ presentModalViewController:imageUploadView animated:YES];
Can anybody please help?
Thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 ViewController 中,在 viewDidLoad 或 ViewWillAppear 中尝试以下操作:
Inside your ViewController, in viewDidLoad or in ViewWillAppear try this:
将其添加为子视图。
Add it as a subview.
我使用下面的代码解决了这个问题
I solved it by using below code