2011-05-12 88 views
1

我已經在iphone中做了一個溫度轉換器的應用程序,我希望當它在模擬器啓動時,只有數字鍵盤應該來,而不是阿爾法鍵盤。如何只使用數字鍵盤

#import "farh_celcius_conv_AppDelegate.h" 

float i; 
float s; 
float p; 

@implementation farh_celcius_conv_AppDelegate 

@synthesize window,display,farhenite,display1; 





-(IBAction) convert { 
    s = ('0','1','2'); 

    if(p == s) 
    { 

    NSString *str = farhenite. text; 

    float n = [str floatValue]; 


    if (n != 0) { 

     k =.5559* (n-32); 
     i = 5*(n -32)/9 +273 ; 

     [display setText:[NSString stringWithFormat:@"%f",k]]; 
     [display1 setText:[NSString stringWithFormat:@"%f",i]];  
    } 
} 
} 

- (void)dealloc { 
    [window release]; 
    [super dealloc]; 
} 


@end 
+0

重複:http://stackoverflow.com/questions/1846777/defaulting-iphone-numeric-keypad – phi 2011-05-12 09:24:09

回答

4

您可以爲您的文本字段設置各種類型的鍵盤。在文本輸入特徵,鍵盤下查看檢查員。

4

試試這個,

yourTextField.keyboardType = UIKeyboardTypePhonePad; 

yourTextField.keyboardType = UIKeyboardTypeNumberPad; 

你也可以做到這一點的筆尖文件。

2
[myTextField setKeyboardType:UIKeyboardTypeNumberPad];