- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我很难找出我的程序崩溃的原因。到目前为止,我有一个主屏幕,它转到带有两个选项卡的 UITabBar,每个选项卡都有 UITableView。在第二个选项卡上,我有一个自定义单元格,如果用户单击它,该单元格应该会提供更多详细信息。所有这些都在 UINavigationController 中。当我在带有表格单元格详细信息的 View Controller 中时,按回车键,然后再次按回车键(我应该在主屏幕上),程序在这里崩溃并显示 EXC_BAD_ACCESS(代码 = 1):
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RaceMeAppDelegate class])); //EXC_BAD_ACCESS }
}
通过查看其他帖子,我尝试使用 Xcode 中的僵尸工具来找出问题所在。我运行了它,它说“一个 objective-c 消息被发送到一个地址为 0x16f19370 的已释放的“MatchCellDetailsViewController”对象(僵尸)。日志看起来像这样:
# Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller
0 Malloc +1 1 00:14.422.351 UIKit -[UIClassSwapper initWithCoder:]
1 Retain +1 2 00:14.430.802 UIKit UINibDecoderDecodeObjectForValue
2 Retain +1 3 00:14.431.402 UIKit -[UIRuntimeConnection initWithCoder:]
3 Retain +1 4 00:14.431.488 UIKit -[UIRuntimeConnection initWithCoder:]
4 Retain +1 5 00:14.431.977 UIKit UINibDecoderDecodeObjectForValue
5 Retain +1 6 00:14.432.136 UIKit UINibDecoderDecodeObjectForValue
6 Retain +1 7 00:14.432.310 Foundation -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
7 Retain +1 8 00:14.432.639 UIKit -[UINib instantiateWithOwner:options:]
8 Release -1 7 00:14.432.964 UIKit -[UINibDecoder finishDecoding]
Release (2) -2 00:14.433.013 UIKit -[UINibDecoder finishDecoding]
10 Release -1 5 00:14.433.134 UIKit -[UINibDecoder finishDecoding]
11 Release -1 4 00:14.433.176 UIKit -[UIRuntimeConnection dealloc]
12 Release -1 3 00:14.433.341 UIKit -[UIRuntimeConnection dealloc]
14 Retain +1 3 00:14.434.055 UIKit -[UIStoryboardSegue initWithIdentifier:source:destination:]
Retain/Release (2) 00:14.434.138 RaceMe -[ReceivedTabTableViewController prepareForSegue:sender:]
17 Retain +1 4 00:14.436.369 UIKit -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:]
Retain/Autorelease/Release (3) 00:14.437.924 UIKit -[UINavigationController topViewController]
Retain/Autorelease/Release (3) 00:14.438.033 UIKit -[UINavigationController topViewController]
Retain/Release (2) 00:14.438.158 UIKit -[UINavigationController pushViewController:transition:forceImmediate:]
Retain/Autorelease/Release (3) 00:14.465.975 UIKit -[UINavigationController topViewController]
25 Retain +1 9 00:14.466.037 libsystem_blocks.dylib _Block_object_assign
26 Retain +1 10 00:14.467.423 UIKit -[UINavigationController topViewController]
27 Autorelease 00:14.467.430 UIKit -[UINavigationController _startDeferredTransitionIfNeeded:]
28 Retain +1 11 00:14.467.467 UIKit -[UINavigationController topViewController]
29 Autorelease 00:14.467.475 UIKit -[UINavigationController _startCustomTransition:]
30 Retain +1 12 00:14.477.542 UIKit -[UINib instantiateWithOwner:options:]
31 Retain +1 13 00:14.484.362 UIKit -[UINib instantiateWithOwner:options:]
32 Retain +1 14 00:14.484.481 UIKit -[UINib instantiateWithOwner:options:]
33 Retain +1 15 00:14.484.582 UIKit +[UIProxyObject addMappings:forCoder:]
34 Retain +1 16 00:14.493.202 UIKit -[UIProxyObject initWithCoder:]
Retain/Release (12) 00:14.493.229 UIKit -[UIRuntimeConnection initWithCoder:]
Retain (4) +4 00:14.494.155 UIKit -[UIRuntimeConnection initWithCoder:]
40 Retain +1 22 00:14.498.045 UIKit -[UIProxyObject initWithCoder:]
46 Release -1 26 00:14.505.411 UIKit -[UINib instantiateWithOwner:options:]
Release (4) -4 00:14.506.686 UIKit -[UINibDecoder finishDecoding]
Release (4) -4 00:14.507.340 UIKit -[UIRuntimeConnection dealloc]
61 Release -1 11 00:14.509.718 Foundation -[NSAutoreleasePool drain]
62 Retain +1 12 00:14.513.293 UIKit -[UINavigationController topViewController]
63 Autorelease 00:14.513.308 UIKit -[UINavigationController _startCustomTransition:]
Retain/Release (2) 00:14.513.330 UIKit -[UINavigationController _startCustomTransition:]
66 Retain +1 13 00:14.513.399 UIKit -[UINavigationController topViewController]
67 Autorelease 00:14.513.407 UIKit -[UINavigationController _startCustomTransition:]
68 Retain +1 14 00:14.513.477 UIKit -[UINavigationController _startCustomTransition:]
69 Release -1 13 00:14.513.642 UIKit -[UINavigationController _startCustomTransition:]
Retain/Autorelease/Release (3) 00:14.514.475 UIKit -[UINavigationController topViewController]
72 Retain +1 15 00:14.719.975 libsystem_blocks.dylib _Block_object_assign
Retain/Autorelease/Release (3) 00:14.722.535 UIKit -[UINavigationController topViewController]
Retain/Release (2) 00:14.723.110 UIKit -[UIResponder becomeFirstResponder]
77 Release -1 15 00:14.762.974 libsystem_blocks.dylib _Block_release
Release (3) -3 00:15.145.440 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
84 Release -1 8 00:15.146.309 UIKit _wrapRunLoopWithAutoreleasePoolHandler
87 Release -1 5 00:15.147.134 UIKit -[UIStoryboardSegue dealloc]
88 Release -1 4 00:15.147.183 UIKit _wrapRunLoopWithAutoreleasePoolHandler
89 Release -1 3 00:15.147.322 UIKit -[UIStoryboardScene dealloc]
90 Retain +1 4 00:15.385.010 UIKit -[UINavigationController topViewController]
91 Autorelease 00:15.385.017 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
Retain/Autorelease/Release (3) 00:15.429.329 UIKit -[UINavigationController topViewController]
94 Retain +1 6 00:15.431.214 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
Release (2) -2 00:15.431.373 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
97 Release -1 3 00:15.433.236 UIKit __destroy_helper_block_119
98 Release -1 2 00:15.433.615 GraphicsServices GSEventRunModal
Retain/Autorelease/Release (3) 00:15.792.024 UIKit -[UINavigationController topViewController]
Retain/Autorelease/Release (3) 00:15.792.321 UIKit -[UINavigationController topViewController]
Retain/Autorelease/Release (6) 00:15.792.807 UIKit -[UINavigationController topViewController]
Retain/Release (2) 00:15.792.878 UIKit -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:]
Release/Retain (2) 00:15.792.899 UIKit _popViewControllerNormal
Retain/Release (2) 00:15.793.576 UIKit _popViewControllerNormal
Retain/Release (8) 00:15.824.455 UIKit -[UINavigationController _startCustomTransition:]
124 Retain +1 4 00:16.554.694 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
126 Retain +1 4 00:16.555.120 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
128 Release -1 2 00:16.555.354 UIKit -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
130 Release -1 0 00:16.559.291 UIKit __destroy_helper_block_119
131 Zombie -1 00:18.098.937 UIKit -[UINavigationController _startCustomTransition:]
我试着看看我是否在我不应该调用的地方调用了 MatchCellDetailsViewController,但是我找不到我在哪里使用了这个类并且会导致问题。第二个选项卡是 MatchCellDetailsViewController 的委托(delegate),因此我可以向后传递数据,但除此之外,我认为我没有进行任何错误的调用。我不太确定 _startCustomTransition 指的是什么。
如果您能帮助我们找出问题所在,我们将不胜感激。谢谢
----编辑----
我认为问题出在这两个类中的某处,我尝试发布代码的更相关部分。
ReceivedTabBarViewController.m(主屏转到这个)
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.tableView reloadData]; //necessary to reload if user switches between tabs
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadMatchesWithCallback:^(NSArray *matches) {
self.matches = matches;
self.matchesMutable = [NSMutableArray arrayWithArray:self.matches];
[self.activityIndicator startAnimating];
if ([self.matches count] == 0) { [self.activityIndicator stopAnimating]; }
for (GKTurnBasedMatch *match in self.matches) {
//Gets the match data
[self loadAndDisplayMatchDataWithCallback:match callback:^(NSData *matchData) {
RaceMeGame *updatedGame = [NSKeyedUnarchiver unarchiveObjectWithData:matchData];
NSString *matchDataString = [NSString stringWithFormat:@"%@ %@ %@ %d", updatedGame.matchDistance, updatedGame.status, updatedGame.score, updatedGame.numberOfTurns];
[self.matchWithMatchData setObject:matchDataString forKey:match.matchID];
NSLog(@"Match data: %@", matchDataString);
NSLog(@"Current number of turns: %d", updatedGame.numberOfTurns);
//Converts the matchID to a GKTurnBasedMatch
[self retrieveMatch:match.matchID callback:^(GKTurnBasedMatch *match) {
GKTurnBasedParticipant *currentPlayerInMatch = [match currentParticipant];
NSArray *currentPlayerIDs = [[NSArray alloc] initWithObjects:currentPlayerInMatch.playerID, nil];
//Converts a player ID to a player's alias
[self retrievePlayerAliases:currentPlayerIDs callback:^(NSArray *players) {
[self.currentPlayerTurnAliasList addObject:((GKPlayer*)[players firstObject]).alias];
if ([self.currentPlayerTurnAliasList count] == [self.matches count]) {
[self.tableView reloadData];
[self.activityIndicator stopAnimating];
}
}];
}];
}];
}
}];
}
- (void)removeReceivedChallenge:(NSInteger)index
{
GKTurnBasedMatch *match = [self.matchesMutable objectAtIndex:index];
//Remove the data from table
[self.matchWithMatchData removeObjectForKey:match.matchID];
[self.matchesMutable removeObjectAtIndex:(NSUInteger)index];
NSIndexPath *myIP = [NSIndexPath indexPathForRow:index inSection:0];
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:myIP] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
}
#pragma mark - MatchCellDetailsViewController Delegate
- (void)indexRemoveViewController:(MatchCellDetailsViewController *)controller didFinishRemovingIndex:(NSInteger)index
{
[self removeReceivedChallenge:index];
}
- (void)moveChallengeToCurrentViewController:(MatchCellDetailsViewController *)controller didFinishMoving:(GKTurnBasedMatch*)match
{
GlobalVars *globals = [GlobalVars sharedInstance];
RaceMeGame *updatedGame = [NSKeyedUnarchiver unarchiveObjectWithData:match.matchData];
NSArray *currentPlayerIDs = [[NSArray alloc] initWithObjects:match.currentParticipant.playerID, nil];
[self retrievePlayerAliases:currentPlayerIDs callback:^(NSArray *players) {
[globals.currentMatches setObject:[[NSDictionary alloc]
initWithObjectsAndKeys:updatedGame.status, ((GKPlayer*)[players firstObject]).alias, nil]
forKey:match.matchID];
if (![globals.currentMatchesHelper containsObject:match.matchID]) {
[globals.currentMatchesHelper addObject:match.matchID];
}
}];
}
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowReceivedChallengeDetails"]) {
MatchCellDetailsViewController *detailViewController = [segue destinationViewController];
NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
long row = [myIndexPath row];
//Distance-Status-Score-NumberOfTurns
NSString *tempMatchString = [self.matchWithMatchData objectForKey:((GKTurnBasedMatch *)[self.matchesMutable objectAtIndex:row]).matchID];
NSArray *tempMatchArrayData = [tempMatchString componentsSeparatedByString:@" "];
detailViewController.distance = [NSString stringWithFormat:@"Distance: %@", [tempMatchArrayData objectAtIndex:0]];
detailViewController.status = [NSString stringWithFormat:@"Game Status: %@", [tempMatchArrayData objectAtIndex:1]];
detailViewController.participant = [NSString stringWithFormat:@"Current Players Turn: %@", [self.currentPlayerTurnAliasList objectAtIndex:row]];
detailViewController.currentNumberOfTurns = [[tempMatchArrayData objectAtIndex:3] intValue];
detailViewController.match = [self.matchesMutable objectAtIndex:row];
detailViewController.rowSelected = (NSInteger)row;
detailViewController.delegate = self;
}
}
MatchCellDetailsViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.delegate = self;
self.distanceLabel.text = self.distance;
self.statusLabel.text = self.status;
self.currentPlayersLabel.text = self.participant;
}
- (IBAction)acceptInvite:(UIButton *)sender {
[self.match acceptInviteWithCompletionHandler:^(GKTurnBasedMatch *match, NSError *error) {
if (error) {
}
else {
if (self.currentNumberOfTurns == 1) {
//advance turn back to the other user
[GameCenterHelper sharedInstance].currentMatch = match;
NSLog(@"Advancing turn");
/***** Preparation to advance turn ******/
//Converting game to NSData and sending it as match data
if ([[GameCenterHelper sharedInstance].currentMatch.matchData bytes] == 0) {
NSLog(@"Match data not created yet, allocating and initializing it");
[GameCenterHelper sharedInstance].gameData = [[RaceMeGame alloc] init];
[[GameCenterHelper sharedInstance] advanceTurn];
NSInteger index = self.rowSelected;
NSLog(@"Index being passed: %d", index);
[self.delegate indexRemoveViewController:self didFinishRemovingIndex:index];
[self.delegate moveChallengeToCurrentViewController:self didFinishMoving:match];
} else {
[[GameCenterHelper sharedInstance] loadAndDisplayMatchDataWithCallback:[GameCenterHelper sharedInstance].currentMatch callback:^(NSData *matchData) {
[GameCenterHelper sharedInstance].gameData = [NSKeyedUnarchiver unarchiveObjectWithData:matchData];
[[GameCenterHelper sharedInstance] advanceTurn];
//Remove this cell from ReceivedChallengesVC
NSInteger index = self.rowSelected;
[self.delegate indexRemoveViewController:self didFinishRemovingIndex:index];
//Send the data to CurrentMatchesVC
//Moves the challenge that the player has accepted the invite to from ReceivedChallengesVC to CurrentChallengesVC
[self.delegate moveChallengeToCurrentViewController:self didFinishMoving:match];
}];
}
} else {
NSLog(@“Error: %@“, error);
}
}
}];
}
最佳答案
Swift iOS:僵尸 UIKit [UINavigationController _startCustomTransition:]我正在使用以下产生错误的代码:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.delegate = self
}// end viewDidLoad
但是一旦我更改了 View 中的委托(delegate),它就会开始工作而没有任何崩溃
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.delegate = self
}
关于ios - EXC_BAD_ACCESS- 返回导航 Controller 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25146694/
Yii::$app->runAction('new_controller/new_action', $params); 我相信这可以用来从另一个 Controller 调用 Controller Ac
这个问题类似于 this ,但我需要访问父成员(不是控制)。我不知道是否可以不使用依赖注入(inject)。 例如,我有一个父级,有一个成员调用用户,我需要从子 Controller 访问用户。 最佳
我有包含 2 个布局的根布局:- 选项面板- 绘制区域 我正在尝试的是访问 OptionsPaneController 中的 DrawAreaController 以调用其绘制方法。下面是 Optio
我的应用程序的 View Controller 层次结构设置如下: UIViewController | UITabBarController | UINavigationCo
我的应用程序的 View Controller 层次结构设置如下: UITabBarController | UINavigationController | | |
当我第一次为我目前在 Storyboard 中开发的应用程序创建基础布局时,我分两步完成: 选择我的 View Controller 并使用 Editor->Embed In->Navigation
设计要求: 显示用户可以选择的项目列表 选择一个项目后,使用后退按钮将用户带到一个新 View 。新 View 应在底部包含第一个屏幕中不存在的选项卡列表 单击选项卡中的项目时,应出现一个带有后退按钮
将父 Controller 设置为“parentCtrl as vm”,并将子 Controller 设置为“childCtrl as vmc”,以避免名称冲突,并且效果良好。 如何在子 Contro
我已经阅读了一些答案,例如关闭当前的 ViewController,但我的情况有所不同,因为我正在展示另一个 ViewController。 虽然我无法访问它的属性,但此代码显示了带有导航 Contr
如我所见,如果我们要实例化一个Model(例如,名为Post),我们只需调用: $post = new Post(); 现在,我还想实例化一个Controller(例如,名为Post,并为此 Cont
我已经疯狂地在整个网络上搜索解决我的问题的方法,但目前还没有。我的问题是我必须检查是否在 HTTP 请求中获得特定文本,该请求在一个 while 循环中,如果我这样做了,那么我应该离开循环并继续线程,
我想用this.get('controllers.pack.query');要得到App.PackQueryController在 App.PackController ,但失败了。 我认为问题是 E
我刚开始使用 Laravel。当我使用 codeigniter 或 zend 框架时,我可以将我的 Controller 组织到一个单独的目录中。例如,我可以创建“user/permission.ph
在 emberjs 前 2 我们可以从另一个 Controller 访问 Controller 或 Controller 中的任何方法 以下方式: App.get('router').get('nav
这可能是非常简单的实现,但我是 iOS 编程的新手,我似乎被卡住了。 所以,基本上,我有一个选项卡式应用程序。我决定除了标签栏之外还需要一个导航栏。为此,我放置了标签栏 Controller ,然后添
我有这个列表 Controller , define([ 'jquery', 'app' ], function ($,app) { app.controller("ListC
我有 3 个 Controller :RootController、FirstController 和 SecondController。我想从 RootController -> FirstCont
我有以下 Controller : /controllers/api/base_controller.rb /controllers/api/v1/articles_controller.rb 当为文
我是 Angular JS 的新手,尝试在另一个 Controller 中调用一个 Controller ,但出现以下错误。 ionic.bundle.js:21157 TypeError: $con
我有一个标签栏 Controller 和它的 3 个 child ,我还有另一个 View ,我制作了一个从 child 到 View Controller 的自定义转场,还有一个从 View Con
我是一名优秀的程序员,十分优秀!