0

我正在使用 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];
4

1 回答 1

0

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

在 Phonegap 中,从 JS 执行:

nativeControls.createToolBarItem("spacer", "", "UIBarButtonSystemItemFlexibleSpace", "");
于 2012-06-15T16:18:54.003 回答