我有一个非常奇怪的问题,我想我知道我为什么得到它,但我似乎无法想到修复。我确信这里没有编译器错误。我有很多这些,所有这些都是因为我的错误代码而发生的。我基本上有一个名为UnlockKeyboardViewController的视图控制器,它继承自UIViewController和一个名为UnlockKeyboard的自定义视图(直接从UIView继承)。对于UnlockKeyboard头看起来是这样的:“编译器错误”,“分割错误11”在自定义视图控制器上
@interface UnlockKeyboard : UIView
{
NSArray *buttons;
NSArray *passcodeFields;
UIImage *buttonBackgroundImage;
UIImage *buttonBackgroundHighlightedImage;
UIImage *middleButtonBackgroundImage;
UIImage *middleButtonBackgroundImageHighlighted;
UIImage *screenBackgroundImage;
UIImage *infoViewContainerImage;
UIImage *keypadViewContainerImage;
UIImage *passcodeFieldsContainerImage;
UIImage *infoViewImage;
UIImage *passcodeViewImage;
UIView *infoViewContainer;
UIView *keypadViewContainer;
UIView *passcodeFieldsContainer;
UIView *infoView;
UIView *keypadView;
UIView *passcodeFieldsView;
UIView *infoToDisplayView; //The view the programmer passes to show in infoView.
}
@property(nonatomic, retain)UIImage *buttonBackgroundImage;
@property(nonatomic, retain)UIImage *buttonBackgroundHighlightedImage;
@property(nonatomic, retain)UIImage *screenBackgroundImage;
@property(nonatomic, retain)UIImage *keypadViewBackgroundImage;
@property(nonatomic, retain)UIImage *infoViewContainerImage;
@property(nonatomic, retain)UIImage *keypadViewContainerImage;
@property(nonatomic, retain)UIImage *passcodeFieldsContainerImage;
@property(nonatomic, retain)UIImage *infoViewImage;
@property(nonatomic, retain)UIImage *passcodeViewImage;
@property(nonatomic, retain)UIView *infoToDisplayView;
//Properties for container views.
@property(nonatomic, retain)UIView *infoViewContainer;
@property(nonatomic, retain)UIView *keypadViewContainer;
@property(nonatomic, retain)UIView *passcodeFieldsContainer;
@end
的UnlockKeyboardViewController实现看起来像这样至今:
@implementation UnlockKeyboardViewController
-(id)init
{
if((self = [super init]))
{
self.view = [[UnlockKeyboard alloc] init];
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[UIView animateWithDuration:0.7 animations:^{
self.view.keypadViewContainer.frame = CGRectMake(0, 261, 320, 200);
} completion:^(BOOL finished){
}];
}
-(void)dealloc
{
[super dealloc];
}
@end
这是我的问题变得有趣。每当我尝试编译,终端(这是一个越狱的应用程序,所以没有Xcode中)给了我以下错误:
In function ‘void __-[UnlockKeyboardViewController viewDidAppear:]_block_invoke_1(void*)’:
Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
,但这个错误,只有当我在这行出现:
self.view.keypadViewContainer.frame = CGRectMake(0, 261, 320, 200);
如果我没有在我的动画块的那一行,编译器不会给我那个错误,它会编译得很好。虽然,无论我把这条线,我总是得到分割线11.
我认为这可能与UIView没有一个名为keypadViewContainer成员的事实,虽然UnlockKeyboard具有该属性,是UIView的一个子类。我相信这是因为编译器实际上看不到UIView和UnlockKeyboard之间的类层次结构。
如果我是对的,我不知道如何解决问题。一直在想。任何输入来帮助我解决这个问题将非常感激。
您正在使用您的视图控制器榫文件?如果没有,'loadView'的基本实现会将你的'UnlockKeyboardViewController'的'view'属性设置为一个常规的'UIView',否定你在'init'中做了什么(你不应该在' init')。 – omz 2012-07-29 01:59:27
你说“no Xcode”;你在用什么编译器? – benzado 2012-07-29 02:00:32
omz:我认为你是对的。我应该尝试在loadView中做这个任务吗?我没有使用任何笔尖或任何东西。这是纯代码,因为我没有使用XCode。我不使用XCode越狱应用程序。 benzado:仍在使用GCC。我只是没有使用XCode作为我的IDE。 – 2012-07-29 02:02:24