0

每当我在设备上的子类 UITextfield 中输入文本时,我都会输入两个或三个字符,然后应用程序就会冻结。无法关闭键盘或触摸任何选项卡。这是 UITextField 子类:

@implementation OAI_TextField

@synthesize elementID;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        colorManager = [[OAI_ColorManager alloc] init];
        fileManager = [[OAI_FileManager alloc] init];

        self.font = [UIFont fontWithName:@"Helvetica" size:20.0];
        self.textColor = [colorManager setColor:66.0 :66.0 :66.0];
        self.borderStyle = UITextBorderStyleRoundedRect;
        self.backgroundColor = [UIColor whiteColor];
        self.returnKeyType = UIReturnKeyDone;
        self.delegate = self;

    }
    return self;
}

#pragma mark Text Field Delegate Methods
- (BOOL)textFieldShouldReturn:(UITextField *)textField {

    [self resignFirstResponder];

    //if project number text field we're going to check and see if the "Project" directory contains the file, if not we'll create it

    //get super view
    UIView* myParent = self.superview;

    //get the subviews
    NSArray* mySiblings = myParent.subviews;

    //get the label
    UILabel* myLabel = [mySiblings objectAtIndex:0];

    //get the label text
    NSString* myLabelText = myLabel.text;

    //check it!
    if ([myLabelText isEqualToString:@"Project Number:"]) {

        NSString* projectNumberPlist = [NSString stringWithFormat:@"%@.plist", self.text];
        NSString* projectNumberPlistPath = [NSString stringWithFormat:@"Projects/%@", projectNumberPlist];

        [fileManager createFile:projectNumberPlist:projectNumberPlistPath];


    }

    return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    NSLog(@"ok");
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end

我将在 - (void)textFieldDidBeginEditing: 中获得 NSLog 调用。我在控制台中没有收到任何错误消息。不太确定从哪里开始调试。有人可以轻推我一下吗?

谢谢

4

0 回答 0