小编Ben*_*men的帖子

在我滚动之前,数据不会加载到UITableView中

我试图在单元格中加载已解析的数据,但问题是它是同步发生的,UitableView在数据加载完成之前不会显示.我试图通过使用performSelectorInBackground解决问题,但现在数据没有加载到单元格中,直到我开始滚动.这是我的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self performSelectorInBackground:@selector(fethchData) withObject:nil];


}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
self.listData = nil;
    self.plot=nil;
}


-(void) fethchData

{
    NSError *error = nil;
    NSURL *url=[[NSURL alloc] initWithString:@"http://www.website.com/"];
    NSString *strin=[[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

    HTMLParser *parser = [[HTMLParser alloc] initWithString:strin error:&error];

    if (error) {
        NSLog(@"Error: %@", error);
        return;
    }

    listData =[[NSMutableArray alloc] init];
    plot=[[NSMutableArray alloc] …
Run Code Online (Sandbox Code Playgroud)

cocoa objective-c synchronous uitableview

53
推荐指数
3
解决办法
2万
查看次数

标签 统计

cocoa ×1

objective-c ×1

synchronous ×1

uitableview ×1