Клавиатурата UITextField не може да въвежда нищо

заредете xib файл като UIView и получих UITextField от Xib файл (това е просто изглед, който съдържа текстово поле и бутон). Но когато приложението се стартира и това текстово поле се появява. не мога да въвеждам никаква азбука в това UITextField. Но поставянето на текст в това UITextField беше ОК. Защо? Ето моя код за добавяне

-(IBAction)showSheet{    
    UIView *myView = [[[NSBundle mainBundle] loadNibNamed:@"LoginViewComp" owner:self options:NULL] lastObject];    
     [myView setFrame:CGRectMake(0, 44, 320, 400)];

    UIButton *btn1 = (UIButton *)[myView viewWithTag:101];
    UITextField *field = (UITextField *)[myView viewWithTag:102];
    UILabel *lbl = (UILabel *)[myView viewWithTag:103];    

    [field setEnabled:YES];

    [btn1 addTarget:self action:@selector(testBtn1) forControlEvents:UIControlEventTouchUpInside];

    DTActionSheet *sheet = [[DTActionSheet alloc] initWithContentView:myView sheetTitle:@"Demo"];
    [sheet showInView:self.view];
    [sheet setUserInteractionEnabled:YES];
}

-(void)testBtn1{
    NSLog(@"btn1 touch up inside");     
}
@end

DTActionSheet.m

@interface DTActionSheet()
@property (nonatomic,strong) UIView* contentView;
@property (nonatomic,strong) UIToolbar* toolBar;
@end

@implementation DTActionSheet
@synthesize contentView=_contentView;
@synthesize toolBar=_toolBar;

-(id)initWithContentView:(UIView*)contentView sheetTitle:(NSString*)title;
{
    self = [super init];
    if (self) 
    {
        _contentView = contentView;
        int btnnum = (contentView.frame.size.height-5)/50; // (height+44-20-25)/50
        for(int i=0; i<btnnum; i++)
        {
            [self addButtonWithTitle:@" "];
        }
        _toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
        _toolBar.barStyle = UIBarStyleBlackOpaque;

        UIBarButtonItem *titleButton = [[UIBarButtonItem alloc] initWithTitle:title 
                                                                        style:UIBarButtonItemStylePlain 
                                                                       target:nil 
                                                                       action:nil];

        UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                        style:UIBarButtonItemStyleDone 
                                                                       target:self
                                                                       action:@selector(done)];

        UIBarButtonItem *leftButton  = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" 
                                                                        style:UIBarButtonItemStyleBordered 
                                                                       target:self 
                                                                       action:@selector(cancel)];

        UIBarButtonItem *fixedButton  = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                                                                                      target:nil 
                                                                                      action:nil];

        [_toolBar setItems: [NSArray arrayWithObjects:leftButton,fixedButton,titleButton,fixedButton,rightButton,nil]];

        [self addSubview:_toolBar];
        [self addSubview:_contentView];
    }
    return self;
}

-(void)done
{
    [self dismissWithClickedButtonIndex:0 animated:YES];
}
-(void)cancel
{
    [self dismissWithClickedButtonIndex:0 animated:YES];
}
@end

Xib компонент

Не мога да въвеждам азбука и число в тези 2 текстови полета

Хей, момчета, имате ли идея?


person sdev    schedule 25.06.2012    source източник
comment
Можете ли да се уверите, че делегатът на вашето текстово поле работи или не?   -  person Praveen-K    schedule 25.06.2012
comment
решихте ли проблема??   -  person Omarj    schedule 21.01.2013


Отговори (1)


опитайте да използвате UIKeyInput Protocol Reference за въвеждане -- http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIKeyInput_Protocol/Reference/Reference.html

не забравяйте да използвате неговия делегат..

person Nishant    schedule 26.06.2012