2016-07-24 2 views
0

이전에 iOS 응용 프로그램이 잘 작동했지만 갑자기 표 셀을 클릭하고 다른보기 컨트롤러를 누를 때마다 충돌이 발생합니다.UITableViewCell에서보기 컨트롤러를 누를 때마다 응용 프로그램이 중단됩니다.

많은 조사를 한 후에 테이블 뷰가 파괴 되었기 때문에 전에 푸시가 발생하지만 이해할 수 없습니다.

응용 프로그램은 Objective-C로 작성되었으며 비 ARC 모드를 사용하는 이전 프로젝트입니다.

오류 메시지

모든 충돌에서 명확하고 변화하지 않았다, 그래서 나는 pushViewController 기능의 NOanimated 플래그를 설정했는데, 지금은 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]; 
} 
+0

VC를 눌러 코드를 표시 할 수 있습니까? vC 또는 iVar입니까? – Joshua

+0

@Joshua 코드 스 니펫을 추가했습니다. 관심과 시간에 감사드립니다. – technophyle

+0

좀비를 사용 설정 했습니까? – Joshua

답변

0

:

는 그리고 이것은 AppDelegate에서 changePage 통지 핸들러입니다. 있다고합니다 (RootViewController.m에서

: [UIImage retain]: message sent to deallocated instance, 그래서 가난한 메모리 관리가 될 수있는 코드를 찾기 시작하고 문제를 일으키는 줄을 발견 -

나는 좀비를 활성화하고 오류 메시지가 발견 모든 뷰 컨트롤러는
- (void)viewDidAppear:(BOOL)animated { 
    ... 

    /* Search button on the nav bar */ 
    UIImage *image = [[UIImage imageNamed:@"ui_tabbar_search.png"] autorelease]; 
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(searchButtonClicked:)]; 
} 

그래서 나는 autoreleasing 이미지 리소스, 그리고 탐색 막대 항목으로 설정)에서 상속됩니다.

나는 어리석은 대답이지만 누군가가 도움을 얻을 수 있기를 바랍니다.

관련 문제