2012-04-11 13 views
0

iPhoneのwebformをクリックすると、青色の「OK」ボタンがUIWebviewでよく見られます。UIWebviewフォームでキーボードのOKボタンを作成するにはどうすればよいですか?

The blue OK button

コードでそれを再作成する簡単な方法はありますか?それとも難しい方法でそれを作り出さなければなりませんか?

最も近いコードはでした:

UISegmentedControl *buttonOK = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"OK"]]; 
    [buttonOK setSegmentedControlStyle:UISegmentedControlStyleBar]; 
    [buttonOK setTintColor:[UIColor colorWithRed:0.25f green:0.51f blue:0.95f alpha:1.0f]]; 
    [buttonOK setFrame:CGRectMake(276, 8, 38, 30)]; 

しかし、同じではありません...

答えて

3

ウェブビューのボタンが行われ、ボタンのスタイルを持つ半透明のUIToolbarを使用しています。

UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Previous", @"Next", nil]]; 
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; 
segmentedControl.tintColor = [UIColor blackColor]; 
segmentedControl.momentary = YES; 

UIBarButtonItem* segmentedControlItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; 
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleDone target:self action:@selector(done:)]; 
UIBarButtonItem* flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL]; 
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)]; 
toolbar.barStyle = UIBarStyleBlack; 
toolbar.translucent = YES; 
toolbar.items = [NSArray arrayWithObjects:segmentedControlItem, flexSpace, item, nil]; 
[self.view addSubview:toolbar]; 
+0

素晴らしいアイデア!これはUIBarButtonItemです – Rodrigo

+0

「Anterior」/「Seguinte」(次へ)ボタンについてです。単なるUISegmentedControlですか、またはUIBarButtonItemですか?私はそれに等しいことをするが、同じではなかった。 – Rodrigo

+0

UICegmentedControlはUIBarButtonItemにラップされています。私はそれを含めるために私のポストのコードを更新しました。 – Shaun

関連する問題