久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在鍵盤頂部添加完成按鈕

Add a done button to the top of the keyboard(在鍵盤頂部添加完成按鈕)
本文介紹了在鍵盤頂部添加完成按鈕的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在制作一個具有 UITextView 的通用應用程序.當應用程序在 iPad 上運行時,右下角有一個按鈕,可以讓我關閉鍵盤.iPhone版本沒有這樣的按鈕.我在一些 iPhone 應用程序上看到了鍵盤頂部的一個欄,它有一個完成選項.是否有一種簡單的方法可以將 iPad 風格的關閉鍵盤按鈕也添加到 iPhone 應用程序中.如果沒有,將完成樣式欄添加到鍵盤頂部的最佳方法是什么?提前致謝.

I am making a universal app that has a UITextView. When the app run on the iPad there is a button on the lower right which enables me to dismiss the keyboard. The iPhone version does not have such a button. I have seen on some iPhone apps a bar on top of the keyboard that has a done option. Is there an easy way to add an iPad style dismiss keyboard button to the iPhone app as well. If not, what is the best way to add a done style bar to the top of the keyboard? Thanks in advance.

推薦答案

請試試這個代碼

 //set up a placeholder variable for the textfield user typing
 UITextView *currentTextView;

-(void)addDoneToolBarToKeyboard:(UITextView *)textView
{
    UIToolbar* doneToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    doneToolbar.barStyle = UIBarStyleBlackTranslucent;
    doneToolbar.items = [NSArray arrayWithObjects:
                       [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                       [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonClickedDismissKeyboard)],
                       nil];
    [doneToolbar sizeToFit];
    textView.inputAccessoryView = doneToolbar;
}

 //remember to set your text view delegate
 //but if you only have 1 text view in your view controller
 //you can simply change currentTextField to the name of your text view
 //and ignore this textViewDidBeginEditing delegate method
 - (void)textViewDidBeginEditing:(UITextView *)textView
 {
     currentTextView = textView;
 }

-(void)doneButtonClickedDismissKeyboard
{
     [currentTextView resignFirstResponder];
}

在你的視圖中添加這個確實加載了

and add this in your view did load

 [self addDoneToolBarToKeyboard:self.textView];

希望有幫助

這篇關于在鍵盤頂部添加完成按鈕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw stars using Quartz Core?(如何使用 Quartz Core 繪制星星?)
Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?(為什么給 addArcWithCenter 一個 0 度的 startAngle 使它從 90 度開始?)
Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在與中心點成給定角度的直線相交的 UIView 矩形上找到 CGPoint)
Which is the best way to estimate measure of photographed things?(哪種方法是估計拍攝物體尺寸的最佳方法?)
How to convert an Int to a Character in Swift(如何在 Swift 中將 Int 轉換為字符)
How to create a hex color string UIColor initializer in Swift?(如何在 Swift 中創建十六進制顏色字符串 UIColor 初始化程序?)
主站蜘蛛池模板: 日韩精品在线视频免费观看 | 久久久久久国产精品免费免费男同 | 国产97在线 | 日韩 | 不卡一区| 精品91久久 | 午夜激情免费 | 亚洲成人999 | 欧美一级精品片在线看 | 亚洲日韩中文字幕一区 | 九九热国产精品视频 | 久久久一区二区三区 | 久久99国产精品 | 久久久久亚洲国产| 精品日本久久久久久久久久 | 精精国产xxxx视频在线播放7 | 午夜精品久久久久久久久久久久久 | 99久久视频 | 亚洲成人日韩 | 欧洲一级毛片 | 欧美a级成人淫片免费看 | 激情麻豆视频 | 日日骚视频 | 成人自拍视频 | 国产在线精品一区二区 | 欧洲色 | 亚洲一区二区三区久久 | 岛国视频 | 欧美一区免费在线观看 | 视频一区二区中文字幕 | 丁香久久 | 91黄在线观看 | 国产a区 | 精品香蕉一区二区三区 | 黄色大片在线 | 欧美一区二区三区在线观看 | 国产乱人伦| 欧美日韩高清免费 | 91porn在线观看| av在线三级| 综合网视频 | 亚洲精品一区二区在线 |