Ios5 无法使用框架uisearchbar初始化

Ios5 无法使用框架uisearchbar初始化,ios5,xcode4.2,uisearchbar,Ios5,Xcode4.2,Uisearchbar,在这篇文章中,当我遵循布伦特·普里迪的答案时,我遇到了问题 看起来每个人对代码都很满意,但我在uisearchbar初始化代码中获得了exc_bad_访问权限,如下所示: 并且出现警告:无法恢复以前选择的帧。在控制台中 有人知道这里出了什么问题吗 更新我的帖子: 将此代码放入实现文件时的实际错误: (void)controllerWillChangeContent:(NSFetchedResultsController *)controller { UITabl

在这篇文章中,当我遵循布伦特·普里迪的答案时,我遇到了问题

看起来每个人对代码都很满意,但我在uisearchbar初始化代码中获得了exc_bad_访问权限,如下所示: 并且出现警告:无法恢复以前选择的帧。在控制台中 有人知道这里出了什么问题吗

更新我的帖子: 将此代码放入实现文件时的实际错误:

    (void)controllerWillChangeContent:(NSFetchedResultsController *)controller 
    {
        UITableView *tableView = controller == self.fetchedResultsController ? self.tableView : self.searchDisplayController.searchResultsTableView;
        [tableView beginUpdates];
    }

(void)controller:(NSFetchedResultsController *)controller 
  didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex 
     forChangeType:(NSFetchedResultsChangeType)type 
{
    UITableView *tableView = controller == self.fetchedResultsController ? self.tableView : self.searchDisplayController.searchResultsTableView;

    switch(type) 
    {
        case NSFetchedResultsChangeInsert:
            [tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

(void)controller:(NSFetchedResultsController *)controller 
   didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)theIndexPath 
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath 
{
    UITableView *tableView = controller == self.fetchedResultsController ? self.tableView : self.searchDisplayController.searchResultsTableView;

    switch(type) 
    {
        case NSFetchedResultsChangeInsert:
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:theIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self fetchedResultsController:controller configureCell:[tableView cellForRowAtIndexPath:theIndexPath] atIndexPath:theIndexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:theIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

(void)controllerDidChangeContent:(NSFetchedResultsController *)controller 
{
    UITableView *tableView = controller == self.fetchedResultsController ? self.tableView : self.searchDisplayController.searchResultsTableView;
    [tableView endUpdates];
}
(void)controllerWillChangeContent:(NSFetchedResultsController*)控制器
{
UITableView*tableView=controller==self.fetchedResultsController?self.tableView:self.searchDisplayController.searchResultsTableView;
[tableView开始更新];
}
(void)控制器:(NSFetchedResultsController*)控制器
didChangeSection:(id)sectionInfo
atIndex:(整数)sectionIndex
forChangeType:(NSFetchedResultsChangeType)类型
{
UITableView*tableView=controller==self.fetchedResultsController?self.tableView:self.searchDisplayController.searchResultsTableView;
开关(类型)
{
案例NSFetchedResultsChangesInsert:
[tableView insertSections:[NSIndexSet IndexBethIndex:sectionIndex]带行动画:UITableViewRowAnimationFade];
打破
案例NSFetchedResultsChangeDelete:
[tableView deleteSections:[NSIndexSet IndexBethIndex:sectionIndex]带RowAnimation:UITableViewRowAnimationFade];
打破
}
}
(void)控制器:(NSFetchedResultsController*)控制器
didChangeObject:(id)一个对象
atIndexPath:(NSIndexPath*)IndeXPath
forChangeType:(NSFetchedResultsChangeType)类型
newindepath:(nsindepath*)newindepath
{
UITableView*tableView=controller==self.fetchedResultsController?self.tableView:self.searchDisplayController.searchResultsTableView;
开关(类型)
{
案例NSFetchedResultsChangesInsert:
[tableView InsertRowsatindExpath:[NSArray arrayWithObject:newIndexPath]带RowAnimation:UITableViewRowAnimationFade];
打破
案例NSFetchedResultsChangeDelete:
[tableView DeleteRowsAndExpaths:[NSArray arrayWithObject:theIndexPath]withRowAnimation:UITableViewRowAnimationFade];
打破
案例NSFetchedResultsChangeUpdate:
[self-fetchedResultsController:controller configureCell:[tableView cellForRowAtIndexPath:theIndexPath]atIndexPath:theIndexPath];
打破
案例NSFetchedResultsChangeMove:
[tableView DeleteRowsAndExpaths:[NSArray arrayWithObject:theIndexPath]withRowAnimation:UITableViewRowAnimationFade];
[tableView InsertRowsatindExpath:[NSArray arrayWithObject:newIndexPath]带RowAnimation:UITableViewRowAnimationFade];
打破
}
}
(void)controllerDidChangeContent:(NSFetchedResultsController*)控制器
{
UITableView*tableView=controller==self.fetchedResultsController?self.tableView:self.searchDisplayController.searchResultsTableView;
[tableView EndUpdate];
}
我希望有人能帮助我。
谢谢

尝试只使用
tableview
,而不是
self。tableview

如果我不使用self而使用tableview,它会说“使用未声明的标识符”tableview。然后尝试使用硬编码的宽度。如果它的工作方式,那么问题可能在tableview中。它仍然显示相同的错误,这里是-->UISearchBar*searchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0,0,300,0)]autorelease];有什么建议吗?实际的错误是在创建(init)uisearchbar时有invite循环,你知道为什么吗?