ios - 在 tableview 显示之前添加加载 View Controller

标签 ios objective-c uitableview uistoryboard uiactivityindicatorview

我有一个 tableView Controller ,用于加载我解析的 XML 数据。这需要一些时间。

- (void)viewDidLoad
{
[super viewDidLoad];

CustomStringParser *customStringParser = [[CustomStringParser alloc] init];

// Set MORE logo in navigation bar
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Navigation"]];

// Download and parse XML data
RXMLElement *rxml = [RXMLElement elementFromXMLData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.morecobalt.co.uk/rss/?t=events"]]];

// Create an array to store each feed
eventsFeeds = [[NSMutableArray alloc] init];

// Loop through XML data
[rxml iterate:@"channel" usingBlock:^(RXMLElement *supportElement) {
    [supportElement iterate:@"item" usingBlock:^(RXMLElement *repElement) {

        // Assign element to string
        NSString *title = [repElement child:@"title"].text;
        NSString *subtitle = [repElement child:@"tagline"].text;
        NSString *description = [repElement child:@"description"].text;
        NSString *imageurl = [repElement child:@"image"].text;
        NSString *startDate = [repElement child:@"start_date"].text;
        NSString *endDate = [repElement child:@"end_date"].text;

        // Assign element value to MoreCobalt.h propertys
        currentFeed = [MoreCobaltEvents alloc];
        currentFeed.title = title;
        currentFeed.subtitle = subtitle;
        currentFeed.imageurl = imageurl;

        // DESCRIPTION FORMATTING
        description = [customStringParser parseHTML:description];
        description = [customStringParser parseLinesMultiple:description];
        description = [customStringParser removeSocialSignifiers:description];
        currentFeed.description = description;

        // DATE FORMATTING
        currentFeed.startDate = [customStringParser formatDate:startDate];
        currentFeed.endDate = [customStringParser formatDate:endDate];

        // Add a new object to the feeds array
        [eventsFeeds addObject:currentFeed];
    }];
}];
}

在解析数据时,我想添加一个带有事件指示器的加载屏幕。我猜这将是一个 subview 。我该怎么做?

注意:我使用的是 Storyboard。下图

enter image description here

最佳答案

只需在您的 xib 上拖一个事件指示器组件。 在您的 .h 文件中声明一个属性。连接起来。

在 viewDidLoad 调用的 .m 文件中。

[self.activityIndicator starAnimating];
[self.activityIndicator.hidesWhenStopped = YES;

然后在您的表加载后调用:

[self.activityIndicator stopAnimating];

不需要 subview 。

关于ios - 在 tableview 显示之前添加加载 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19706151/

相关文章:

iphone - AVPlayer 不是从 NSCachesDirectory 播放?

ios - UITableViewCell indentationLevel 在 iOS 8 中不起作用

swift - 重新加载后 tableview 持久化单元格图像

ios - Storyboard中的自定义 TableView 单元格布局似乎无效

ios - iOS 旋转后 subview Controller 高度为零

ios - 自定义委托(delegate) null

objective-c - gdata objective-c上传照片报错400 photo data must be set(picasa)

ios - 使用 GCDWebServer 将 UIImage 发送到 LocalwebServer

ios - swift - 我很笨,我的 subview 不会服从并正确调整自身大小

ios - 重复本地通知会删除之前待处理的本地通知