我正在尝试在modalViewController上添加activityIndicator。
基本上,我想开始动画这个activityIndicator后,用户按下这个按钮上的modalViewController。但实际情况是,在这个modalViewController上触发presentModalViewController之前,我所做的一切都保持不变,也就是说,如果我简单地添加activityIndicator,并在呈现modalView之后,那么即使我启动它,它也不会显示出来。但是,如果在预设这个modalViewController之前,如果我触发了activity startAnimating;,那么在呈现modalView之后,activity就会显示为动画。
所以基本上,我想简单地在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];有人能帮帮忙吗?
提前谢谢。
发布于 2010-07-24 14:42:57
在你的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发布于 2010-07-15 21:47:58
将其添加为子视图。
发布于 2014-09-16 18:43:03
我用下面的代码解决了这个问题
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];https://stackoverflow.com/questions/3255651
复制相似问题