我用c ++和100%opengl为iphone编写游戏 我需要添加游戏中心,以便显示UIViews我必须做一些hackish。
void sb_socialShowAchievementsView(){
SocialDelegate* del = [[[SocialDelegate alloc] init] autorelease];
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil) {
achievements.achievementDelegate = del;
HelperViewController* hvc = [[[HelperViewController alloc] init] autorelease];
[globalGLView addSubview:hvc.view];
[hvc presentModalViewController: achievements animated: YES];
}
[achievements release];
}
SocialDelegate实施协议GKAchievementViewControllerDelegate
和GKLeaderboardViewControllerDelegate
。
globalGLView
是我的EAGLView
个实例。
和HelperViewController
只是一个UIViewController
子类。
问题是,当我调用sb_socialShowAchievementsView()
时,应用程序收到带有以下调用堆栈和消息的SIGABRT:
*** Assertion failure in -[UIButtonLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UILabel.m:312
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color'
#0 0x98ece156 in __kill
#1 0x98ece148 in kill$UNIX2003
#2 0x98f60899 in raise
#3 0x98f769b8 in abort
#4 0x961a2fda in __gnu_cxx::__verbose_terminate_handler
#5 0x03022333 in _objc_terminate
#6 0x961a117a in __cxxabiv1::__terminate
#7 0x961a11ba in std::terminate
#8 0x961a12b8 in __cxa_throw
#9 0x03022481 in objc_exception_throw
#10 0x02e8b238 in +[NSException raise:format:arguments:]
#11 0x022c6e37 in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
#12 0x0052260f in -[UILabel setTextColor:]
#13 0x005ec3d3 in -[UIButton layoutSubviews]
#14 0x002a0481 in -[CALayer layoutSublayers]
#15 0x002a01b1 in CALayerLayoutIfNeeded
#16 0x004bd976 in __-[UINavigationController _positionNavigationBarHidden:edge:]_block_invoke_1
#17 0x0043698f in +[UIView(Animation) _performWithoutAnimation:]
#18 0x004c1e26 in -[UINavigationController _positionNavigationBarHidden:edge:]
#19 0x004bd9ae in -[UINavigationController _positionNavigationBarHidden:]
#20 0x004bc0c3 in -[UINavigationController _updateBarsForCurrentInterfaceOrientation]
#21 0x004b99b1 in -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
#22 0x004c0bfd in -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:]
#23 0x0044217f in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#24 0x00440d94 in -[UIView(Hierarchy) _postMovedFromSuperview:]
#25 0x00439c30 in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#26 0x00437f83 in -[UIView(Hierarchy) addSubview:]
#27 0x0049355b in -[UITransitionView transition:fromView:toView:]
#28 0x006a3a16 in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]
#29 0x004b710d in -[UIViewController presentModalViewController:withTransition:]
#30 0x0007ee96 in sb_socialShowAchievementsView at social-bindings-iphone.mm:184
我无法得到我做错的事情......
答案 0 :(得分:0)
我遇到了完全相同的问题。我有一个班级管理我几个月前写的所有游戏中心的东西,它工作得很好。我试图将它导入到一个新项目中,并调用标准方法来呈现GKAchievementViewController
,然后它与你拥有的相同的SIGABRT崩溃了。然后我尝试首先验证播放器(在调用成就控制器之前我通常会这样做),问题就消失了。我想这是GameKit
框架中的一个错误。我无法提交错误报告,因为错误报告显然有它自己的错误:)