刷新 UITableView 不起作用



在视图控制器中有一个UITableView,在最后一部分的最后一行,有一个Facebook登录和注销按钮作为切换。如果用户登录,它会自动转为注销,反之亦然。问题是当登录控制在 safari 中退出应用程序然后返回并视图自动刷新时,但在注销时 UITableView 不会重新加载。下面是我正在使用的代码。

NSHTTPCookie *cookie;
        NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (cookie in [storage cookies])
        {
            NSString* domainName = [cookie domain];
            NSRange domainRange = [domainName rangeOfString:@"facebook"];
            if(domainRange.length > 0)
            {
                [storage deleteCookie:cookie];
                isFb = 0;
                [tableView_detailsEdit reloadData];
                [[FBSession activeSession] closeAndClearTokenInformation];
            }
        }
        isFb = 0;
        [[FBSession activeSession] closeAndClearTokenInformation];
        [tableView_detailsEdit reloadData];

问题是未调用 UITableView 委托方法。因此,表视图中单元格上的文本在注销登录后不会更改。请指导以上。

使用以下

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
     [tableView_detailsEdit reloadData];
}];

double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds *  NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
     [tableView_detailsEdit reloadData];
});

最新更新