在 modalViewController iphone 上添加 ActivityIndi​​cator

发布于 2024-09-09 22:32:20 字数 1057 浏览 5 评论 0原文

我正在尝试在 modalViewController 上添加 ActivityIndi​​cator。

基本上我想在用户按下此 modalViewController 上的按钮后开始为该 ActivityIndi​​cator 制作动画。但是发生的事情是,在这个 modalViewController 上触发presentModalViewController之前我所做的一切都保持不变,即如果我只是添加activityIndi​​cator并在呈现modalView之后,那么即使我启动它它也不会显示。但是如果在预设这个 modalViewController 之前如果我触发 [activity startAnimating];然后在呈现 modalView 活动后显示动画。

所以基本上,我想简单地在 modalViewController 上添加 ActivityIndi​​cator 并在按下按钮后开始为其设置动画。

我正在使用以下代码:

  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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

塔塔猫 2024-09-16 22:32:20

在 ViewController 中,在 viewDidLoad 或 ViewWillAppear 中尝试以下操作:

  CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0);
  loading = [[[UIActivityIndicatorView alloc] initWithFrame:frame] autoRelease];
  [loading sizeToFit];
  loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
  UIViewAutoresizingFlexibleRightMargin |
  UIViewAutoresizingFlexibleTopMargin |
  UIViewAutoresizingFlexibleBottomMargin);
  [self.view addSubView:loading];
  loading.startAnimateing

Inside your ViewController, in viewDidLoad or in ViewWillAppear try this:

  CGRect frame = CGRectMake(140.0, 410.0, 25.0, 25.0);
  loading = [[[UIActivityIndicatorView alloc] initWithFrame:frame] autoRelease];
  [loading sizeToFit];
  loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
  UIViewAutoresizingFlexibleRightMargin |
  UIViewAutoresizingFlexibleTopMargin |
  UIViewAutoresizingFlexibleBottomMargin);
  [self.view addSubView:loading];
  loading.startAnimateing
记忆で 2024-09-16 22:32:20

将其添加为子视图。

Add it as a subview.

锦爱 2024-09-16 22:32:20

我使用下面的代码解决了这个问题

 activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

 // Set Center Position for ActivityIndicator

 activityIndicatorObject.center = CGPointMake(150, 250);
 activityIndicatorObject.backgroundColor=[UIColor grayColor];

 // Add ActivityIndicator to your view
 [self.view addSubview:activityIndicatorObject];

 activityIndicatorObject.hidesWhenStopped=NO;

 [activityIndicatorObject startAnimating];

I solved it by using below code

 activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

 // Set Center Position for ActivityIndicator

 activityIndicatorObject.center = CGPointMake(150, 250);
 activityIndicatorObject.backgroundColor=[UIColor grayColor];

 // Add ActivityIndicator to your view
 [self.view addSubview:activityIndicatorObject];

 activityIndicatorObject.hidesWhenStopped=NO;

 [activityIndicatorObject startAnimating];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文