先生我是新的iphone我創建UITextField使用此代碼,但是當我釋放此dealloc應用程序崩潰。我想通過編碼來創建文本字段。 在此先感謝。iphone-textfield發佈導致崩潰的應用程序
#import "TextField.h"
@implementation TextField
UILabel *label;
UITextField *textField;
- (void)viewDidLoad
{
[super viewDidLoad];
//Create label
label = [[UILabel alloc] init];
label.frame = CGRectMake(10, 10, 300, 40);
label.textAlignment = UITextAlignmentCenter;
label.text = @"";
[self.view addSubview:label];
[label release];
// Initialization code
textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 50)];
textField.delegate = self;
textField.placeholder = @"<Enter Text>";
textField.textAlignment = UITextAlignmentCenter;
[self.view addSubview: textField];
[textField release];
}
- (void)dealloc
{
[textField release];
[label release];
[super dealloc];
}
@end
你能張貼在控制檯上會崩潰嗎? – NoobMe