![](/img/trans.png)
[英]Adding toolbar item or button on DetailViewController ToolBar for iPad
[英]Adding a UITextview as a toolbar item
我正在為iPhone創建一個消息傳遞應用程序。 我希望用戶能夠在按下返回的同時輸入換行符。 但我在工具欄項目中放置UITextview時遇到問題。 我已經看到了與UITextView相同的內容。 當按下返回鍵時,我想在UITextField中獲取新行。這可能是這樣。
請提前幫助,謝謝。
您無法使用IB添加它,但您可以通過編程方式進行添加。 您需要設置其contentInset
以便在編輯時不會推送文本內容,因為由於文本視圖的約束大小,內容將變為不可見。 我在下面的示例代碼中添加了它。
UITextView * textView = [[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 32)] autorelease];
textView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
UIBarButtonItem * barItem = [[[UIBarButtonItem alloc] initWithCustomView:textView] autorelease];
self.toolbar.items = [NSArray arrayWithObject:barItem];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.