繁体   English   中英

单击UIBarButtonItem重新加载RSSFeed

[英]Reload a RSSFeed on clicking a UIBarButtonItem

我是iOS开发的新手,没有太多编程经验。 我要么想从我遵循以下教程的RSS feed中重新加载UITableView ,要么: RSS教程

我只是似乎无法为其添加一个重新加载按钮,因为有时它第一次无法加载,并且想在顶部栏中添加一个按钮以重新加载数据。

就像我说的那样,我几乎没有Objective-C的经验,但是任何帮助将不胜感激。

以下代码是刷新Feed的代码的一部分:

- (void)viewDidLoad {
    [super viewDidLoad];    
    self.title = @"News";
    self.allEntries = [NSMutableArray array];
    self.queue = [[[NSOperationQueue alloc] init] autorelease];
    self.feeds = [NSArray arrayWithObjects:@"http://yourllanelli.org.uk/index.php?format=feed&type=atom",
        nil];    
    [self refresh];

    _reloadButton = [[[UIBarButtonItem alloc]
                                       initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered
                                       target:self action:@selector(reloadClick)]  autorelease];
}

-(void)reloadClick {    
    [UITableView refresh];
}

当调用reloadClick动作时,您实际上并没有从RSS提要中再次获取数据。

您想调用您的refresh方法,一旦您的ASIHTTPRequests全部完成,您就想调用[UITableView reloadData]

-(void)reloadClick
{    
    [self refresh];
}

- (void) requestDidFinish:(ASIHTTPRequest *)request {
     // you need to reload your UITableView once your ASIHTTPRequests finish.
     // since you are sending many requests to get the contents of different feeds, 
     // it would be better to call the following line only once, 
     // when all of the requests have finished
     [UITableView reloadData];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM