UIRefreshControl not refreshing xml data

让人想犯罪 __ 提交于 2019-12-13 06:24:46

问题


Im new here and am stumped trying to add a pull to refresh control to update my xml table view. I'm getting the proper pull to refresh animation, but the data is not refreshing. Please help.

- (void)viewDidLoad {
    [super viewDidLoad];
    feeds = [[NSMutableArray alloc] init];
    NSURL *url = [NSURL URLWithString:@"http://www.PLACEHOLDER.rss.xml"];
    parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
    [parser setDelegate:self];
    [parser setShouldResolveExternalEntities:NO];
    [parser parse];
    UIRefreshControl *refreshControl = [UIRefreshControl new];
    [refreshControl addTarget:self action:@selector(refresh:) 
        forControlEvents:UIControlEventValueChanged];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull 
        to refresh..."];
    self.refreshControl = refreshControl;

}

- (void)refresh:(UIRefreshControl *)sender {
    // ...refresh code
    NSURL *url = [NSURL URLWithString:@"http://www.PLACEHOLDER.rss.xml"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    (void)[[NSURLConnection alloc] initWithRequest:request delegate:self];

    [sender endRefreshing];
}

来源:https://stackoverflow.com/questions/21447330/uirefreshcontrol-not-refreshing-xml-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!