我已经使用故事板构建了一个 iOS 7 应用程序。在我的 offerViewController 中,我有一个 UIView 和一个 UITableView。UIView 充当子视图,在解析我的提要时显示加载消息。完成后,子视图将被删除,我的解析数据将显示在我的 UITableView 中。
@interface OffersViewController ()
@end
@implementation OffersViewController
@synthesize loadingView;
MoreCobaltOffers *currentFeed;
AppDelegate *appDelegate;
- (void)viewDidAppear:(BOOL)animated
{
[self.tableView addSubview:loadingView];
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Navigation"]];
CustomStringParser *customStringParser = [[CustomStringParser alloc] init];
// Download and parse XML data
RXMLElement *rxml = [RXMLElement elementFromXMLData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.myrssfeed.com"]]];
// Create an reference to AppDelegate
appDelegate = [[UIApplication sharedApplication] delegate];
// Create an array to store each feed
appDelegate.offersFeeds = [[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 *address = [repElement child:@"address"].text;
// Assign element value to MoreCobalt.h propertys
currentFeed = [MoreCobaltOffers alloc];
currentFeed.title = title;
currentFeed.imageurl = imageurl;
currentFeed.addressline = address;
// DESCRIPTION FORMATTING
description = [customStringParser parseHTML:description];
description = [customStringParser parseLinesMultiple:description];
description = [customStringParser removeSocialSignifiers:description];
description = [customStringParser appendTermsOfUse:description];
currentFeed.description = description;
// SUBTITLE FORMATTING
subtitle = [customStringParser parseHTML:subtitle];
subtitle = [customStringParser parseLinesSingle:subtitle];
subtitle = [customStringParser removeSocialSignifiers:subtitle];
currentFeed.subtitle = subtitle;
// Add a new object to the feeds array
[[appDelegate offersFeeds] addObject:currentFeed];
}];
//Remove the loading screen
[loadingView removeFromSuperview];
//Show table data, if this is not here the table is empty.
[self.tableView reloadData];
}];
}
当我运行应用程序时,会出现加载屏幕,然后表格会显示数据。如果我从这个视图控制器导航到另一个选项卡,然后导航回来,表格将闪烁。用户体验不是很好。
负责的代码行是[self.tableView reloadData];
. 我需要这个,否则表会变空。我究竟做错了什么?