我正在尝试找出创建加载UIView
的最佳方法,同时将数据从数据库加载到UIViewController
或将数据加载到UITableViewController
如下所示:
谢谢!
答案 0 :(得分:0)
#import "MBProgressHUD.h"
in .h
-(UIView *)viewForIndicator
{
//UIWindow *__autoreleasing win = [UIApplication sharedApplication].keyWindow;
//UIView *__autoreleasing view = [win.subviews lastObject];
//return view;
UIWindow *__autoreleasing win = nil;//[UIApplication sharedApplication].keyWindow;
NSArray* arrWindows = [UIApplication sharedApplication].windows;
for (UIWindow* w in arrWindows) {
if ([w isKindOfClass:[UIWindow class]]) {
win = w;
break;
}
}
UIView *__autoreleasing view = nil;
for(int i=(int)[win.subviews count]-1;i>=0;i--){
view=[win.subviews objectAtIndex:i];
if(![view isKindOfClass:[UIAlertView class]]){
break;
}
}
return view;
}
然后用它来显示
[MBProgressHUD showHUDAddedTo:[self viewForIndicator] animated:YES];