好吧,我的RSS应用程序运行完美,现在我正在尝试使用MBProgressHUD添加一些指标.
我在ViewDidLoad下的View Controller中实现了这段代码
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; HUD.labelText = @"Loading"; [HUD show:YES];
到现在为止还挺好.该指标正在发挥作用,但当然永远不会消失.我是新手,我试图在实现文件的某些部分添加到我的[HUD隐藏:是]但是它不起作用.如何在数据加载完成后隐藏指示器?这是我的实现文件.
@implementation ListadoArticulosViewController - (void)viewDidLoad { [super viewDidLoad]; // HUD setting HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; HUD.labelText = @"Loading"; [HUD show:YES]; NSURL *feedURL = [NSURL URLWithString:@"http://girlsonlyapp.wordpress.com/feed/"]; feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL]; feedParser.delegate = self; feedParser.feedParseType = ParseTypeFull; feedParser.connectionType = ConnectionTypeAsynchronously; listadoArticulos = [[NSMutableArray alloc] init]; UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(cargaArticulos) forControlEvents:UIControlEventValueChanged]; self.refreshControl = refreshControl; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self cargaArticulos]; } - (void)cargaArticulos { [feedParser parse]; } #pragma mark MWFeedParserDelegate - (void)feedParserDidStart:(MWFeedParser *)parser { NSLog(@"Comienza el parseo"); // We emptied the list of items to avoid accumulating // in subsequent calls [listadoArticulos removeAllObjects]; // We put up the refresh Control [self.refreshControl beginRefreshing]; } - (void)feedParser:(MWFeedParser *)parser didParseFeedInfo:(MWFeedInfo *)info { // Once we have recovered the items we // The name of the blog as the view controller title self.title = @"titles"; } - (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item { // Add the item to the array downloaded [listadoArticulos addObject:item]; } - (void)feedParserDidFinish:(MWFeedParser *)parser { // Como ya ha finalizado el parse, denemos el parser [feedParser stopParsing]; // Detenemos el refresh control [self.refreshControl endRefreshing]; // Refrescamos el table view [self.tableView reloadData]; // trying to do something } - (void)feedParser:(MWFeedParser *)parser didFailWithError:(NSError *)error { NSLog(@"Ha ocurrido un error al tratar de recuperar los artículos."); // En caso de que este funcionando el refresh control y // se produzca un error, lo detenemos. if ([self.refreshControl isRefreshing]) { // Detenemos el refresh control [self.refreshControl endRefreshing]; } } #pragma mark UITableViewDelegate / UITableViewDataSource -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ArticuloCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ArticuloCell"]; MWFeedItem *item = [listadoArticulos objectAtIndex:indexPath.row]; cell.titulo.text = item.title; // Guy Cohen - this is the second label that we can customize , orignally it was link, but it changed // it to summary cell.descripcion.text = item.summary; return cell; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return listadoArticulos.count; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { ArticuloCell *celda = (ArticuloCell *)sender; MWFeedItem *item = [listadoArticulos objectAtIndex:[self.tableView indexPathForCell:celda].row]; DetalleViewController *detalleVC = (DetalleViewController *)segue.destinationViewController; [detalleVC setItem:item]; } @end
Sean.. 5
我可以推荐使用SVProgressHUD
吗?
https://github.com/samvermette/SVProgressHUD
你只需要打电话[SVProgressHUD show]
和[SVProgressHUD dismiss]
我可以推荐使用SVProgressHUD
吗?
https://github.com/samvermette/SVProgressHUD
你只需要打电话[SVProgressHUD show]
和[SVProgressHUD dismiss]