我在一个新闻应用程序中工作。我有六个不同的消息。我从 viewwillappear() 方法调用 rss 提要。我已经使用 selectedIndex 运行了一个开关盒。我包括了延迟加载,但从 rss 加载新闻仍然需要很长时间。任何可能的解决方案?提前致谢
(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
noNewsLabel.hidden=YES;
bdNewsParser=[[[BDNewsParser alloc] init]retain];
if (loadingFlag==1)
{
ImgesName=[[NSMutableArray alloc] init];
dicImages_msg = [[NSMutableDictionary alloc] init];
}
if (loadingFlag!=2)
{
NSLog(@"newsTypeInd:%@",newsTypeInd);
[newsCat setText:[newsTypeInd objectAtIndex:selectedIndex]];
[newsTitleArray removeAllObjects];
[newsDescriptionArray removeAllObjects];
[newsLinkArray removeAllObjects];
[newsPublicationDate removeAllObjects];
[newsImageLinkArray removeAllObjects];
[newsSourceArray removeAllObjects];
switch(selectedIndex)
{
case 0:
[bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/itnews.php"];
break;
case 1:
[bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/internationalnews.php"];
break;
case 2:
// [bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/bangladeshnews.php"];
[self showAlert];
break;
case 3:
//[bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/businessnews.php"];
[self showAlert];
break;
case 4:
[bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/entertainmentnews.php"];
break;
case 5:
[bdNewsParser loadXMLByURL:@"http://amarhost.info/fuad/newsainment/sportnews.php"];
break;
default:
break;
}
newsTitleArray=bdNewsParser.titleArray;
newsDescriptionArray=bdNewsParser.descriptionArray;
newsLinkArray=bdNewsParser.linkArray;
newsPublicationDate=bdNewsParser.publicationDateArray;
newsImageLinkArray=bdNewsParser.newsImageArray;
newsSourceArray=bdNewsParser.newsSourceArray;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
// [self filterArrayGroupWise:selectedIndex];
if ([newsTitleArray count]==0) {
NSLog(@"Hide contrrol");
[self hideControls];
noNewsLabel.hidden=NO;
}
else {
[self showControls];
noNewsLabel.hidden=YES;
[self setupScrollview];
ImgesName = newsImageLinkArray;
[self reloadScrolview];
}
savedTitleArr=[userDefault readArrayFromUserDefaults:@"FavoriteTitle"];
if (savedTitleArr)
{
if ([savedTitleArr containsObject:[newsTitleArray objectAtIndex:pageNo]])
{
[saveButton setEnabled:NO];
}
else
{
[saveButton setEnabled:YES];
}
}
else
{
[saveButton setEnabled:YES];
}
}
indicatorAnimatingFlag=0;
[activityView stopAnimating];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[scrollView addGestureRecognizer:singleTap];
pageNo=0;
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * 0;
frame.origin.y = 0;
[scrollView setBounds:frame];
[bdNewsParser release];
index=0;
selectedIndex=0;
}