【问题标题】:How to debug on the iPhone itself without xcode? UISearchBar/DisplayController crashes如何在没有 xcode 的情况下在 iPhone 上进行调试? UISearchBar/DisplayController 崩溃
【发布时间】:2011-10-08 21:54:25
【问题描述】:

我有一个问题:我正在编写一个使用 searchBar 和 tableView 的应用程序。

当我点击搜索栏时,输入一些要搜索的字符串,一旦我点击取消按钮,或者删除所有搜索词并再次点击 tableView,我的应用程序就会崩溃。

当我在 iOS 模拟器中运行应用程序时,它不会崩溃。

当我通过 xcode 在我的 iPhone 上运行该应用程序时,它不会在执行此操作时崩溃。

我不太了解设备日志,我想问一下是否有任何方法可以找出发生了什么严重错误以及为什么在通过 xcode 执行此操作时没有发生这种情况。请帮帮我!

PS:设备日志之一:(也许你们都明白)

编辑:这是 searchDisplayControllerDidEndSearch 方法的代码:

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller 
{    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [UIView beginAnimations:@"DeactivateSearch" context:nil];
    [UIView setAnimationDuration:0.4];
    [self.attractionsTableView setFrame:CGRectMake(0, 43, 320, 362)];
    [UIView commitAnimations];


    NSFetchRequest *fetchRequest = [[self fetchedResultsController] fetchRequest];

    [fetchRequest setPredicate:nil];

    NSError *error = nil;
    if (![[self fetchedResultsController] performFetch:&error]) {
        // Handle error
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }  

    [self setSearchIsActive:NO];

    return;
}

更新:如果没有输入文本,搜索栏不会崩溃。因此,只需激活 searchBar 并在不输入的情况下将其停用即可。但只要我输入了一个字符,停用过程就会使应用程序崩溃。

【问题讨论】:

    标签: ios xcode crash uisearchbar uisearchdisplaycontroller


    【解决方案1】:

    查找动画回调问题。还有一个控制台日志,看看吧。

    【讨论】:

    • 日志在管理器中可用。至于你的代码,你写的太认真了。带有块的回调可能会比调用者更长寿,需要将它们复制到堆中。
    • 我对 Objective-C 还很陌生,所以我不明白什么是动画回调。我将编辑我的问题并在其中添加 searchDisplaycontrollerDidEndSearch 函数,也许您可​​以看到问题所在。
    • 我认为是从 SearchDisplayController 中删除 tableView 导致了问题,但我不知道为什么以及出于什么原因:/
    【解决方案2】:

    我自己找到了答案。。

    在我的一个自定义单元格中,我经常发布一些东西,因此当 UISearchDisplayController 为搜索结果发布 UITableView 时应用程序崩溃了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      • 2016-03-19
      • 1970-01-01
      相关资源
      最近更新 更多