简体   繁体   English

如何在iPhone的View Controller中的TableView中重新加载数据

[英]How can I reload data in tableview in view controller in iphone

I am new to iphone development. 我是iPhone开发的新手。 I have created 5 buttons in the view. 我在视图中创建了5个按钮。 On clicking the buttons it navigates to the corresponding views. 单击按钮后,它将导航到相应的视图。 On clicking the "News" button it navigates and displayed the parsing details in the table view.(This table view, I have created View controller and added table view using Interface Builder and I have set all the properties.) and I go to another button and comes back to the "News" button, every time parsing will happened.How to avoid the multiple parsing when I come back to the button. 单击“新闻”按钮时,它将导航并在表视图中显示解析详细信息。(此表视图已创建View控制器,并使用Interface Builder创建了表视图,并设置了所有属性。),然后转到另一个按钮,然后返回到“新闻”按钮,每次都会进行解析。当我回到该按钮时,如何避免多次解析。

I have tried this one and my code is, 我已经尝试过了,我的代码是,

 - (void)viewDidAppear:(BOOL)animated {

     [super viewDidAppear:animated];

     static int i;

     if(i == 0)
     {
          NSString * path = @"http://www.AAAAAAAAAAAAAA.com";

         [self parseXMLFileAtURL:path];

         i++;

     }

      [self.newsTable reloadData];

  }

Now the parsing is happened only one time but the datas are not displayed. 现在解析仅发生一次,但数据不会显示。

My problem is the tableview does not reload. 我的问题是tableview无法重新加载。 newsTable is the instance of the Tableview. newsTable是Tableview的实例。

How can I achieve this? 我该如何实现?

Please help me out. 请帮帮我。

  [self.newsTable reloadData];

put this line on click of news button. 将此行放在“新闻”按钮上。

it reloads the table view whenever you click. 只要单击,它就会重新加载表格视图。 since view did load calls only one time thats why no reload of table view take place. 因为视图只加载一次调用,所以为什么没有重新加载表视图。

I suppose, that you are using NSXMLParser. 我想,您正在使用NSXMLParser。

The parser has a few delegate methods that you'll want to implement: 解析器有一些您要实现的委托方法:

parser:didStartElement:namespaceURI:qualifiedName:attributes: 
parser:didEndElement:namespaceURI:qualifiedName:
parserDidEndDocument:

So, you just need to put reloadData invocation into parserDidEndDocument: 因此,您只需要将reloadData调用放入parserDidEndDocument:

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

相关问题 如何从另一个视图 controller 保存数据并重新加载 tableview? - How to save data from another view controller and reload tableview? 如何从另一个视图控制器将数据插入到tableView中? - How can I insert data into a tableView from another view controller? 如何在WatchKit tableview中重新加载数据? - How can I reload the data in a WatchKit tableview? 如何使用视图控制器 (swift) 重新加载 tableview - How to reload tableview using view controller (swift) iOS Swift如何从其他控制器重新加载tableView - IOS Swift how can I reload a tableView from a different controller 如何在swift 4中正确地在tableview控制器单元内的tableview中重新加载数据? - how to reload data in tableview inside tableview controller cell correctly in swift 4? 我在一个视图控制器上有两个 TableView,如何根据点击的 TableView 将数据传递给单独的视图控制器? - I have two TableViews on a single View Controller, how can I pass data to a separate View Controller based upon which TableView was tapped? 如何在iOS的表格视图控制器中重新加载数据? - How can reload the data in table view controller in iOS? 如何快速从另一个视图控制器重新加载 tableview - How to reload tableview from another view controller in swift 如何使用tableview重新加载以下viewcontroller? - How can I reload the following viewcontroller with a tableview?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM