scrolling を作成するにはどうすればよいですUIToolbar
か? キーボードの上に追加のアクセサリ ボタンがあり、その幅をスクロールすることもできますか? Day One や Byword のように。
編集:私はで使用していますUITextView
Byword から
これは、入力アクセサリ ビューで行ったことです。既にバー ボタン項目を実装しています。水平方向にスクロールして、より多くのボタンを表示できるかどうかに興味があります。
scrolling を作成するにはどうすればよいですUIToolbar
か? キーボードの上に追加のアクセサリ ボタンがあり、その幅をスクロールすることもできますか? Day One や Byword のように。
編集:私はで使用していますUITextView
Byword から
これは、入力アクセサリ ビューで行ったことです。既にバー ボタン項目を実装しています。水平方向にスクロールして、より多くのボタンを表示できるかどうかに興味があります。
scrollview 内のすべてのボタンを含む 1 つのビューを作成し、そのビューを inputAccessoryView または TextField として割り当てます。あなたが私の答えを得ることを願っています。
要件に基づいていくつかのバー ボタンを作成し、それらを配列に追加します。ビュー内にスクロールビューを作成します。そして、スクロールビューを入力アクセサリビューとしてテキストフィールドに与えます。
例を次に示します。 1. 要件に基づいてバー ボタンを作成します。
UIBarButtonItem* button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)];
UIBarButtonItem* button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(done:)];
UIBarButtonItem* button3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(done:)];
UIBarButtonItem* button4 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(done:)];
UIBarButtonItem* button5 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRedo target:self action:@selector(done:)];
それらを配列に追加する
NSArray *itemsArray = [NSArray arrayWithObjects:button1,button2,button3,button4,button5,nil];
UIView 内にスクロールビューを作成する
UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.frame = toolbar.frame;
scrollView.bounds = toolbar.bounds;
scrollView.autoresizingMask = toolbar.autoresizingMask;
scrollView.showsVerticalScrollIndicator = true;
scrollView.showsHorizontalScrollIndicator = true;
scrollView.scrollEnabled = YES;
//scrollView.bounces = false;
UIView *superView = toolbar.superview;
[toolbar removeFromSuperview];
toolbar.autoresizingMask = UIViewAutoresizingNone;
toolbar.frame = CGRectMake(0, 0, 400, toolbar.frame.size.height);
toolbar.bounds = toolbar.frame;
[toolbar setItems:itemsArray];
scrollView.contentSize = toolbar.frame.size;
[scrollView addSubview:toolbar];
[superView addSubview:scrollView];
inputAccessoryView
textFieldに scrollview を追加する
self.textField.inputAccessoryView = scrollView;
テキストの編集を開始するときに、uiview アニメーションを設定する必要があります。
[UIView beginAnimations:nil context:nil];
CGRect rect=self.view.frame;
rect.origin.y=-50;
self.view.frame=rect;
[UIView commitAnimations];
編集終了後
[UIView beginAnimations:nil context:nil];
CGRect rect=self.view.frame;
rect.origin.y=0;
self.view.frame=rect;
[UIView commitAnimations];