views:

974

answers:

2

Hi,

I'm playing around with this application I got on last months Web Designer that's a very basic RSS reader. I would like to add a refresh button to the top navigation bar that refreshes all the content in the table but can't seem to work out how to do it. I've worked out it must somehow use the [tablename Reload] function, but have got no idea how to implement it.

I'm new to all this so simple instructions are good instructions :) I know how to add the button, its linking it to and defining the actions when the user clicks it that I'm struggling with.

You can grab the code here http://www.webdesignermag.co.uk/tutorial-files/issue-162-tutorial-files/ under iPhone Apps (it's the only one).

A: 

Hi Graeme and velcome to SO.

For the iphone UI, you have to define outlets and actions, and use Interface Builder to link them together.

This page has some information that should hopefully get you started.

Understanding Outlets and Actions

Alan
Thanks! I was looking for some more specifics to this situation though (i.e. the reloading of the table from the button). Any ideas for that?
Graeme
A: 

This is what you need to do in the RootViewController.m:

  • In the viewDidLoad function, add a button of type UIBarButtonSystemItemRefresh, associate to it an Action and a Target, (infact, as Alan told you, you need to learn about Outlets and Actions)

    UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshTable)];
    self.navigationItem.rightBarButtonItem = refreshButton;
    
  • Implement refreshTable function (if not declared in .h, have to put it above viewDidLoad())

     - (void)refreshTable{
            [rssParser release];
            rssParser = [[RSSXMLParser alloc] init];
            [rssParser parseRSSFeed];   
            [self.tableView reloadData];
            NSLog(@"table is refreshing ...."); 
     } 
    
sfa
Thanks that's just what i was looking for. Is there an easy way to add the reloading icon in the top status bar while its refreshing?
Graeme
if you want to know more, I suggest you to follow the tutorial at this link: http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss-reader-using-touchxml-part-1/
sfa