我一直在尝试调整UIAlertView中的IndicatorView的位置,但它永远不会起作用.我试图设置loadingIndicator loadingIndicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50)但它根本不适用,看看这张照片:

alert = UIAlertView(title: "Loading...", message: nil , delegate: nil, cancelButtonTitle: nil)
loadingIndicator = UIActivityIndicatorView(frame: CGRectMake(50, 10, 37, 37))
loadingIndicator.center = self.view.center
loadingIndicator.hidesWhenStopped = true
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
loadingIndicator.startAnimating();
alert.setValue(loadingIndicator, forKey: "accessoryView")
loadingIndicator.startAnimating()
alert.show();
Run Code Online (Sandbox Code Playgroud) 我正在编写一个iPad应用程序,当在webview中加载页面时,该应用程序具有UIWebView和活动指示器.我认为这是一个愚蠢的问题,但我怎样才能确保活动指标始终居中?如果我有垂直,它居中,但如果我水平转动iPad,活动指示器现在位于左下象限而不是中心.
提前致谢!
我有一个像这样编写的自定义UIWebView:
@interface MiniWebViewController : UIViewController {
NSString* destinationURL;
UIWebView* webView;
UIActivityIndicatorView* activityIndicatorView;
}
@property (nonatomic, retain) NSString* destinationURL;
@property (nonatomic, retain) IBOutlet UIWebView* webView;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView* activityIndicatorView;
- (void) run;
@end
Run Code Online (Sandbox Code Playgroud)
@synthesize destinationURL;
@synthesize webView;
@synthesize activityIndicatorView;
- (id) initWithFrame:(CGRect)frame {
if (self = [super initWithNibName:@"MiniWebView" bundle:nil]) {
self.destinationURL = @"";
self.view.frame = frame;
self.activityIndicatorView.center = self.webView.center;
}
return self;
}
- (void) run {
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.destinationURL]]];
}
Run Code Online (Sandbox Code Playgroud)
它被称为从另一个ViewController启动:
- (void) aFunction { …Run Code Online (Sandbox Code Playgroud) 我的UITableView顶部有一个navigationBar.我在navigationBar右侧有一个刷新按钮.
单击刷新按钮时,我需要启动活动指示器,刷新表并停止活动指示器.
-(void)refreshClicked{
[spinner startAnimating]; //UIActivityIndicatorView object
[appDelegate readJSONData]; //this is the method which populates the array
//for displaying in the tableview
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何在填充数组后刷新表,然后如何停止活动指示器.
谢谢 :)
我正在尝试将UIActivityIndicator添加到我的自定义视图(以编程方式).我使用以下代码.但我在屏幕上看不到任何东西.知道为什么吗?
谢谢.
UIActivityIndicatorView *activityIndicator=[[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(75, 395, 200, 200)] autorelease];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center=self.view.center;
[self.view addSubview:activityIndicator];
Run Code Online (Sandbox Code Playgroud) 我想在我的应用中使用活动指示器.
我在我的应用程序中使用JSON解析.首先,当我显示数据下载活动指示器时单击同步按钮,下载完成时停止.
同样isuue在这里,当应用程序启动数据下载时,我也在应用程序中放置活动指示器.
我正在使用以下方法进行连接...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
}
Run Code Online (Sandbox Code Playgroud) 我希望在tableView加载之前有一个“正在加载”视图控制器。您可以推荐执行此操作的最佳方法吗?如果可能,请提供一些代码。
理想情况下,加载屏幕将具有活动指示和标有加载的标签。
在UITableView上方添加一个UIView。

我的app委托有两种方法来启动和停止活动指示器.我需要在后台线程上调用它们,以便它始终可见.像这样:
[self.delegate performSelectorInBackground:@selector(acionarActivityIndicator) withObject:nil];
Run Code Online (Sandbox Code Playgroud)
要么
[NSThread detachNewThreadSelector:@selector(acionarActivityIndicator) toTarget:self.delegate withObject:nil];
Run Code Online (Sandbox Code Playgroud)
两者都是一样的.
假设这是VCA按钮单击,然后VCB在加载所有内容后,我在我的应用程序委托中调用另一个方法来停止动画.我在后台对两个视图执行其他操作以获取我的数据.
活动指标工作正常.问题是,过了一段时间,我的应用程序中的所有动画都停止工作.我觉得这与此有关,但我不确定.
如果我尝试更快地进行屏幕转换,我会更早地收到此错误.那有意义吗?
App Delegate方法:
- (void)acionarActivityIndicator {
// Show the activity indicator
self.view = [[UIView alloc] init];
self.activityIndicator = [[UIActivityIndicatorView alloc] init];
self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
self.view.frame = self.window.bounds;
self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = self.view.frame;
self.activityIndicator.center = CGPointMake(frame.size.width/2, frame.size.height/2);
[self.view addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
[self.window addSubview:self.view];
[self.window makeKeyAndVisible];
}
- (void)pararActivityIndicator
{
// metodo parar activity indicator
[self.view removeFromSuperview];
[self.activityIndicator …Run Code Online (Sandbox Code Playgroud) 许多应用程序使用一个小的中心黑色圆角矩形,当一个动作被调用以保存网络的东西,通常包含一个throbber.
他们在ios中叫什么?UIActionSheets?
当我想保存某些东西时,如何创建一个?
我有一个带有UIActivityIndicatorView的TableViewController作为子视图,而内容加载并且它的工作方式应该如此.唯一的问题是我无法将活动指示器置于屏幕中心.
CGFloat width = CGRectGetWidth(self.view.bounds);
CGFloat height = CGRectGetHeight(self.view.bounds);
loadingIndicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(width / 2, height / 2, 125, 125)];
loadingIndicator.center = CGPointMake(width / 2, height / 2);
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
loadingIndicator.hidesWhenStopped = YES;
[self.tableView addSubview:loadingIndicator];
[loadingIndicator startAnimating];
Run Code Online (Sandbox Code Playgroud) ios ×6
iphone ×5
objective-c ×4
uitableview ×2
hide ×1
ios7 ×1
ipad ×1
swift ×1
uialertview ×1
view ×1
webview ×1
xcode ×1