如何向 iPhone RSS 阅读器应用添加刷新按钮?

发布于 2024-08-15 22:41:53 字数 454 浏览 1 评论 0原文

我正在使用上个月在 Web Designer 上获得的这个应用程序,它是一个非常基本的 RSS 阅读器。我想在顶部导航栏中添加一个刷新按钮,以刷新表中的所有内容,但似乎无法弄清楚如何做到这一点。我已经弄清楚它必须以某种方式使用 [tablename Reload] 函数,但不知道如何实现它。

我对这一切都很陌生,所以简单的说明就是很好的说明:)我知道如何添加按钮,将其链接到并定义用户单击它时我正在努力解决的操作。

您可以在此处获取代码 http://www.webdesignermag iPhone Apps 下的 .co.uk/tutorial-files/issue-162-tutorial-files/(这是唯一的一个)。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的呼吸 2024-08-22 22:41:53

这是您需要在 RootViewController.m 中执行的操作:

  • 在 viewDidLoad 函数中,添加一个 UIBarButtonSystemItemRefresh 类型的按钮,将其关联到一个 Action 和一个 Target,(事实上,正如 Alan 告诉您的那样,您需要了解渠道和行动)

    UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshTable)];
    self.navigationItem.rightBarButtonItem = 刷新按钮;
    
  • 实现刷新表函数(如果没有在.h中声明,必须将其放在viewDidLoad()之上)

     - (void)refreshTable{
            [rssParser 发布];
            rssParser = [[RSSXMLParser alloc] init];
            [rssParser parseRSSFeed];   
            [self.tableView reloadData];
            NSLog(@"表格正在刷新......"); 
     } 
    

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 ...."); 
     } 
    
撩心不撩汉 2024-08-22 22:41:53

嗨,格雷姆,欢迎来到 SO。

对于 iPhone UI,您必须定义插座和操作,并使用 Interface Builder 将它们链接在一起。

此页面包含一些希望可以帮助您入门的信息。

了解插座和操作

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文