如何在将数据加载到UIViewConroller Swift时创建加载UIView

时间:2015-04-05 12:00:19

标签: ios xcode swift uiview uiviewcontroller

我正在尝试找出创建加载UIView的最佳方法,同时将数据从数据库加载到UIViewController或将数据加载到UITableViewController

如下所示:

谢谢!

enter image description here

1 个答案:

答案 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];

Github Link