2015-04-05 51 views
-2

我试图找出创建装载UIView的最佳方式,而将数据从数据库加载到UIViewController或加载数据到UITableViewController如何创建在加载数据到UIViewConroller斯威夫特

一个加载的UIView类似以下内容:

谢谢!

enter image description here

+1

只要搜索github上,有很多不同的LOADI ng views https://github.com/search?q=activity+indicator&type=Repositories&utf8=%E2%9C%93 – Arbitur 2015-04-05 12:07:51

回答

0
#import "MBProgressHUD.h" 
在.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

+0

看来,MBProgressHUD是第三方类(在Github上提供)。任何时候您在第三方代码中使用一个帖子,你应该明确陈述这个事实,以及一个链接。 – 2015-04-05 15:43:39