久久久久久久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 初始化程序?)
主站蜘蛛池模板: 精品99久久久久久 | 麻豆久久久久久久 | 国产91在线播放精品91 | 日韩三区在线 | 作爱视频免费看 | 亚洲日本成人 | 成年人在线视频 | 久久精品亚洲精品 | 日韩有码在线播放 | 国产网站在线免费观看 | 欧美狠狠操 | 亚洲国产精品va在线看黑人 | 99综合| 91在线视频免费观看 | 欧美激情综合五月色丁香小说 | 亚洲一区中文字幕在线观看 | 久久久精品一区二区三区四季av | 久久久91精品国产一区二区三区 | 黑人精品欧美一区二区蜜桃 | 91久久国产综合久久91精品网站 | 免费看一区二区三区 | 久久精品国产一区二区电影 | 成人二区 | 成人h片在线观看 | 久久久精彩视频 | 久久久久久国产免费视网址 | 天天天操 | 一级片免费视频 | 一区二区三区在线免费观看视频 | 亚洲一级淫片 | 九九精品在线 | 国产精品视频偷伦精品视频 | 日日夜夜影院 | 国产精品久久 | 人碰人操 | 乱码av午夜噜噜噜噜动漫 | 久久久国产一区二区三区 | 国产精品久久久久久久久久久久午夜片 | 欧美mv日韩mv国产网站91进入 | 国产成人免费一区二区60岁 | 天堂亚洲网 |