2012-01-16 121 views
5

我想找到一種方法來突出顯示標準ios鍵盤上的返回按鈕,但我找不到任何文檔。突出顯示iOS鍵盤上的「返回」按鈕

有人知道該怎麼做嗎?

非常感謝您的回答。

+0

下一次,您發佈之前,請記住,簽名是不允許的,根據常見問題解答,並請檢查您的帖子是否有拼寫和語法錯誤。 – 2012-01-16 14:27:28

+0

好吧,thanx,我不知道... – reinvdo 2012-01-17 08:50:24

+0

官方的蘋果文檔顯示'去'buttonhighlighted(http://developer.apple.com/library/IOs/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/ KeyboardManagement.html#// apple_ref/DOC/UID/TP40009542-CH5-SW3)。 這是如何完成的? – reinvdo 2012-01-20 16:00:36

回答

4

返回按鈕無法突出,突出顯示的狀態存在的UIReturnKeyType不同的值:

typedef enum { 
    UIReturnKeyDefault, 
    UIReturnKeyGo, 
    UIReturnKeyGoogle, 
    UIReturnKeyJoin, 
    UIReturnKeyNext, 
    UIReturnKeyRoute, 
    UIReturnKeySearch, 
    UIReturnKeySend, 
    UIReturnKeyYahoo, 
    UIReturnKeyDone, 
    UIReturnKeyEmergencyCall, 
} UIReturnKeyType; 

藍色的亮點在所有的這些似乎除了UIReturnKeyDefault(這亦是一個寫着「返回」 )。

可以在符合UITextInputTraits(例如UITextFieldUITextView[id <UITextInputTraits> returnKeyType]任何文本輸入控制設置UIReturnKeyType

0

我想喲想定製您的textView多一點,我找到了一個關於how to add a custom button to the keyboard的例子。這個代碼日期2008年3月,我可以不上iOS5的工作,但你能得到的想法:

@synthesize window; 
@synthesize viewController; 

- (void)applicationDidFinishLaunching:(UIApplication *)application {  

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 
    window.backgroundColor = [UIColor blackColor]; 
    [window addSubview:viewController.view]; 
    [window makeKeyAndVisible]; 
} 

- (void)keyboardWillShow:(NSNotification *)note { 

    //The UIWindow that contains the keyboard view 
    UIWindow* tempWindow; 

    //Because we cant get access to the UIKeyboard throught the SDK we will just use UIView. 
    //UIKeyboard is a subclass of UIView anyways 
    UIView* keyboard; 

    //Check each window in our application 
    for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; C++) 
    { 
     //Get a reference of the current window 
     tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c]; 

     //Get a reference of the current view 
     for(int i = 0; i < [tempWindow.subviews count]; i++) 
     { 
      keyboard = [tempWindow.subviews objectAtIndex:i]; 

      if([[keyboard description] hasPrefix:@"(lessThen)UIKeyboard"] == YES) 
      { 
       //Keyboard is now a UIView reference to the UIKeyboard we want. From here we can add a subview 
       //to th keyboard like a new button 
       dot = [UIButton buttonWithType:UIButtonTypeCustom]; 
       dot.frame = CGRectMake(0, 163, 106, 53); 
       [dot setImage:[UIImage imageNamed:@"period.gif"] forState:UIControlStateNormal]; 
       [dot setImage:[UIImage imageNamed:@"period2.gif"] forState:UIControlStateHighlighted]; 
       [keyboard addSubview:dot]; 
       [dot addTarget:self action:@selector(addDot:) forControlEvents:UIControlEventTouchUpInside]; 

       return; 
      } 
     } 
    } 
}