繁体   English   中英

使用PhoneGap将UIBarButtonItem放置在UIToolBar中

[英]Position a UIBarButtonItem in a UIToolBar with PhoneGap

我正在使用PhoneGap 1.3,并试图在工具栏的右侧创建一个iOS添加按钮; 但是, createToolBarItem方法没有任何选项来设置项目的位置。 我怎样才能做到这一点? 这是NativeControls.h的代码片段:

//create the toolbar in `createToolBar` method://
toolBar = [[UIToolbar alloc] initWithFrame:toolBarBounds];

//....set some toolbar options like .hidden, .barStyle, etc.//
[toolBar setFrame:toolBarBounds];
[self.webView setFrame:webViewBounds];

//add the toolbar to the webview
[self.webView.superview addSubView:toolBar];


//create the button item in `createToolBarItem` method:
item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd target:self action:@selector(toolBarButtonTapped:)];
[toolBarItems insertObject:item atIndex:[tagId intValue]];
[item release];

//then in `showToolBar` method//
[toolBar setItems:toolBarItems animated:NO];

您可能现在已经发现了,但是必须在按钮的左侧添加UIBarButtonSystemItemFlexibleSpace才能使其右对齐。

在Phonegap中,通过JS执行:

nativeControls.createToolBarItem("spacer", "", "UIBarButtonSystemItemFlexibleSpace", "");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM