이전에 iOS 응용 프로그램이 잘 작동했지만 갑자기 표 셀을 클릭하고 다른보기 컨트롤러를 누를 때마다 충돌이 발생합니다.UITableViewCell에서보기 컨트롤러를 누를 때마다 응용 프로그램이 중단됩니다.
많은 조사를 한 후에 테이블 뷰가 파괴 되었기 때문에 전에 푸시가 발생하지만 이해할 수 없습니다.
응용 프로그램은 Objective-C로 작성되었으며 비 ARC 모드를 사용하는 이전 프로젝트입니다.
오류 메시지
모든 충돌에서 명확하고 변화하지 않았다, 그래서 나는pushViewController
기능의
NO
에
animated
플래그를 설정했는데, 지금은
EXC_BAD_ACCESS
마다 얻고있다.
어떻게 오류 위치를 좁히고이 자극적 인 버그를 해결할 수 있습니까?
업데이트 : 정보가 하나 더 있습니다. xib
파일이있는 다른보기 컨트롤러의 경우 성공적으로 푸시됩니다. 이는 코드에 의해 생성 된 뷰 컨트롤러에서만 발생합니다. 여기
는 코드 추진 뷰 컨트롤러 단편이다 : 위의 코드에서
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath* pagePath = [[self.pageIndexPath indexPathByAddingIndex:indexPath.section] indexPathByAddingIndex:indexPath.row];
NSString *viewController = [[ContentStore contentStore] viewControllerForPage:pagePath];
if (viewController) {
NSString *title = [[ContentStore contentStore] titleForPage:pagePath];
UIViewController *testVC = [[NSClassFromString(viewController) alloc] init];
testVC.navigationItem.title = title;
NSLog(@"%@", self.parentVC.navigationController.viewControllers);
[self.parentVC.navigationController pushViewController:testVC animated:NO];
} else {
NSString *remoteUrl = [[ContentStore contentStore] remoteURLForPage:pagePath];
DownloadManager *manager = [DownloadManager sharedManager];
if (remoteUrl && (![manager isRemoteResourceMarkedForDownload:remoteUrl] || ![manager isRemoteResourceDownloaded:remoteUrl])) {
[[DownloadManager sharedManager] markRemoteResource:remoteUrl forDownload:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadTables" object:nil];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:@"ChangePage"
object:nil
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:pagePath,@"ChangePage",
@"YES", @"Animate",@"YES",@"Remapped",@"NO",@"Sandbox",nil]];
}
}
}
, if (viewController)
절 수행하지도 (충돌 결과 어디에 해당 뷰 컨트롤러 xib
년대 및 클래스 있다). 내가 마지막으로 문제를 해결 한
- (void)changePage:(NSNotification*)notification {
NSIndexPath* pathIndex = [[notification userInfo] objectForKey:@"ChangePage"];
NSString* shortcut = [[notification userInfo] objectForKey:@"Shortcut"];
bool animate = [[[notification userInfo] objectForKey:@"Animate"] boolValue];
bool sandbox = [[[notification userInfo] objectForKey:@"Sandbox"] boolValue];
//bool remapped = [[[notification userInfo] objectForKey:@"Remapped"] boolValue];
NSString* words = [[notification userInfo] objectForKey:@"Words"];
//NSLog(@"changePage: %@ animate=%d sandbox=%d ", pathIndex,animate,sandbox);
if (pathIndex.length==0) {
pathIndex = [[ContentStore contentStore] pathIndexForShortcutId:shortcut];
if (pathIndex.length==0) {
pathIndex = [NSIndexPath indexPathWithIndex:0];
}
}
[Flurry logEvent:@"ChangePage" withParameters:[NSDictionary dictionaryWithObject:pathIndex forKey:@"Path"]];
NSUInteger selectedTab = [pathIndex indexAtPosition:0];
UINavigationController* nvc = nil;
if (self.tabBarController.viewControllers.count>selectedTab)
nvc = [self.tabBarController.viewControllers objectAtIndex:selectedTab];
if (!nvc) return; // Exit for non-existing tabs.
NSMutableArray *stack =[NSMutableArray arrayWithArray:nvc.viewControllers];
// Pop viewcontrollers until pathIndex has a partial match.
while(true) {
BaseViewController* last = [stack lastObject];
if (!last) break;
if (pathIndex.length < last.pageIndexPath.length) {
[stack removeLastObject];
} else {
bool match = YES;
for(NSUInteger position=0;position<last.pageIndexPath.length;position++) {
if ([pathIndex indexAtPosition:position] != [last.pageIndexPath indexAtPosition:position]) {
match = NO;
break;
}
}
if (match) {
break;
} else {
[stack removeLastObject];
}
}
}
for(NSUInteger position=((BaseViewController*)[stack lastObject]).pageIndexPath.length;position+1<pathIndex.length;position+=2) {
BaseViewController* last = [stack lastObject];
NSIndexPath* newPageIndex = [[last.pageIndexPath indexPathByAddingIndex:[pathIndex indexAtPosition:position]] indexPathByAddingIndex:[pathIndex indexAtPosition:position+1]];
BaseViewController* newVC = [self createViewControllerWithPageIndexPath:newPageIndex parentViewController:[stack lastObject]];
if ([newVC isKindOfClass:WebViewController.class]) {
[(WebViewController*)newVC setSandboxed:sandbox];
[(WebViewController*)newVC setWords:words];
}
if (!newVC) break; // Fail in path, stop
[stack addObject:newVC];
}
// Set the stack
[nvc setViewControllers:stack animated:animate];
[self.tabBarController setSelectedIndex:selectedTab];
[self showDisclaimer];
}
VC를 눌러 코드를 표시 할 수 있습니까? vC 또는 iVar입니까? – Joshua
@Joshua 코드 스 니펫을 추가했습니다. 관심과 시간에 감사드립니다. – technophyle
좀비를 사용 설정 했습니까? – Joshua