【问题标题】:Position a UIBarButtonItem in a UIToolBar with PhoneGap使用 PhoneGap 在 UIToolBar 中定位 UIBarButtonItem
【发布时间】:2012-01-26 17:31:33
【问题描述】:

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

//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];

【问题讨论】:

    标签: objective-c ios xcode cordova uitoolbaritem


    【解决方案1】:

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

    在Phonegap中,从JS做:

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

    【讨论】:

      猜你喜欢
      • 2012-01-04
      • 1970-01-01
      • 2012-03-24
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 2012-06-05
      • 1970-01-01
      • 2017-11-18
      相关资源
      最近更新 更多