Also ich kenne den Grund für diesen Fehler, aber ich bin nicht wirklich sicher, wie ich es umgehen soll.'NSInternalInconsistencyException', Grund: 'Nur auf dem Hauptthread ausführen!' Fehler
Ich habe eine TextField
, die ich nicht bearbeiten möchte, aber mit Scrollen in einer Ansicht aktiviert.
Dies ist, wie ich festgelegt, dass die Ansicht auf:
- (void)tableView:(UITableView *) tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *component = self.resultsTuples[indexPath.row];
NSString* serverUrl = @"http://staging.toovia.com";
NSString* pageLink = component[@"$element"][@"ContactCard"][@"PageLink"];
NSString* recUrl =[NSString stringWithFormat:@"%@%@&format=json&fields=summary&fields=session_info", serverUrl,pageLink];
[AJAXUtils getAsyncJsonWithUrl:(NSURL *)[NSURL URLWithString:recUrl] callback:^(NSDictionary *returnjson){
if (returnjson != nil){
NSLog(@"RETURN JSON : %@", returnjson);
NSString *userPageLink = returnjson[@"Node"][@"SessionInfo"][@"PostingAs"][@"Key"];
self.detailController.userPageLink = userPageLink;
self.detailController.nodePage = returnjson[@"Node"][@"Key"];
NSString *selectedCard = component[@"$element"][@"Title"];
// [self.detailController setDescription:component[@"element"][@"ContactCard"][@"Description"]];
[self.detailController setPageTitle:selectedCard];
NSString* photoUrl = component[@"$element"][@"ContactCard"][@"Cover"][@"Medium"][@"Link"];
[self.detailController setRestaurantImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:photoUrl]]]];
self.detailController.title = selectedCard;
NSString* rating = component[@"$element"][@"Summary"][@"AverageRating"];
self.detailController.rating =(NSInteger)rating;
[self.navigationController pushViewController:self.detailController animated:YES];
}
}];
Dies ist der viewWillAppear
Code für die Ansicht:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear: animated];
self.rateView.notSelectedStar =[UIImage imageNamed:@"star-off.png"];
self.rateView.fullSelectedStar = [UIImage imageNamed:@"star-on.png"];
self.rateView.rating = self.rating;
self.rateView.editable = YES;
self.rateView.maxRating = 5;
self.rateView.delegate = self;
_pageTitleLabel.text = _pageTitle;
_pageScoreLabel.text = _pageScore;
_trendingImageView.image = [UIImage imageNamed:@"trending.png"];
_restaurantImageView.image = _restaurantImage;
}
Der vollständige Fehler ist -
2013-12-16 01:22:50.362 ReviewApp[7332:441f] *** Assertion failure in void _UIPerformResizeOfTextViewForTextContainer(NSLayoutManager *, UIView<NSTextContainerView> *, NSTextContainer *, NSUInteger)(), /SourceCache/UIFoundation_Sim/UIFoundation-258.1/UIFoundation/TextSystem/NSLayoutManager_Private.m:1510
2013-12-16 01:22:50.365 ReviewApp[7332:441f] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'
I So Ich vermute, es passiert, weil die Größenänderung des Textfelds (wenn der Inhalt eingestellt ist) auf der Haupt-Bedroung. Wie kann ich dies erzwingen/diesen Fehler unterdrücken? Ich habe nicht die Kontrolle über das Textfeld Größenanpassung bin ich?
Dank
Vermutlich im Callback-Block für 'getAsyncJsonWithUrl'? – Wain
Ich bin nicht vertraut mit 'getAsyncJsonWithUrl', aber mit dem Namen würde ich vermuten, dass es auf einem Hintergrundthread ist. Suchen Sie nach Dokumenten zum Ausführen eines Selektors im Hauptthread oder zum Senden eines Blocks an die Hauptwarteschlange. –