1
Ich bin Daten aus dem Dienst wie folgt, aber Seitencontroller wird nicht aktualisiert.Reload PageController funktioniert nicht
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBar.hidden = YES;
self.nElements = [[NSMutableArray alloc] init];
self.nTempElements = [[NSMutableArray alloc] init];
[self loadFromURL];
dispatch_async(dispatch_get_main_queue(), ^{
[self.pageController setViewControllers:[NSArray arrayWithObject:
[self
viewControllerAtIndex:0]]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
});
}
-(void)loadFromURL {
if([self.nElements count]){
[self.nElements removeAllObjects];
}
if([self.nTempElements count]){
[self.nTempElements removeAllObjects];
}
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"http://www.xxxxx.com.tr/api/news.json" parameters:nil progress: nil success:^(NSURLSessionTask * _Nonnull operation, id responseObject) {
if(responseObject != NULL) {
for (id jsonItem in [responseObject valueForKey:@"news"])
{
MainNewsData *dicItem = [[MainNewsData alloc]initWithDictionary:jsonItem];
[self.nElements addObject:dicItem];
[self.nTempElements addObject:[jsonItem valueForKey:@"resim"]];
}
}
} failure:^(NSURLSessionTask * _Nullable operation, NSError * _Nonnull error) {
}];
}
Versuchen Sie, die Methode 'setViewControllers' in den Hauptthread zu setzen. –
Ich habe aufgrund Ihrer Rückmeldungen aktualisiert, aber es ist immer noch das gleiche Problem. – hotspring