[英]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.