2013-03-25 111 views
-2

新手到APP開發,我得到一個問題。當我創建我的文本,然後用戶點擊文本鍵盤出現時,我怎麼能禁用鍵盤來?iPhone應用程序禁用UITextField鍵盤

你能幫我嗎?

這裏是我的UITextField文本代碼:

UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(108, 31, 105, 22)]; 
[contentView addSubview:textField1]; 
textField1.alpha = 1.0; 
textField1.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; 
textField1.text = @"my talent"; 
textField1.borderStyle = UITextBorderStyleNone; 
textField1.textAlignment = UITextAlignmentCenter; 
textField1.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; 
textField1.textColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]; 
textField1.font = [UIFont fontWithName:@"Helvetica" size:17.0]; 
[textField1 release]; 
+0

使用'UILabel'僅讀取數據。 – viral 2013-03-25 11:46:41

回答

1

您可以使用此代碼

textField1.userInteractionEnabled = FALSE; 
+0

謝謝你的工作完美! – 2013-03-27 18:01:29

2

UITextField是輸入文字,如果你只是想顯示文本,使用UILabel

1

試試這個

textField1.userInteractionEnabled = TRUE; 
2

你可以寫你的UIViewController

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ 
    return NO; 
} 

但如果你只是想顯示文本,你應該使用UILabel。你真的想用它做什麼?

1

第一組委託,然後使用以下方法

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    return NO; 
}