0

実際、ナビゲーションバーの右側にバーボタンを配置していますが、機能していません。しかし、左バーボタンのアイテムとして使用すると、正常に機能します。私はios5を使用しています。

左右のバーボタンの両方がある場合も機能しませんでした。次に、両方のフレームを設定すると、これらは機能します。しかし、右側にボタンが1つしかない場合、機能しません。

 UIButton *but1 = [UIButton buttonWithType:UIButtonTypeCustom];//customising map button.

but1.frame = CGRectMake(270,0,50,40);       

[but1 addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];//on cilcking an map button clicked method is called.

buttonRight = [[UIBarButtonItem alloc]initWithCustomView:but1];//setting map button on Navigation bar.

self.navigationItem.rightBarButtonItem = buttonRight;//setting button on the Right of navigation bar.

このエラーを追跡する方法は?

4

3 に答える 3

2
UIBarButtonItem *addButton=[[UIBarButtonItem alloc]initWithTitle:@"edit" style:UIBarButtonItemStyleBordered target:self action:@selector(edit_details)];
self.navigationItem.rightBarButtonItem=addButton;

Check it Wil work

于 2011-10-31T10:48:55.387 に答える
1
    UIToolbar* toolbar = [[UIToolbar alloc]
                          initWithFrame:CGRectMake(0, 0, 50, 45)];
    [toolbar setBarStyle: UIBarStyleBlackOpaque];
    // create an array for the buttons
    NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:0];

    // create a standard BarButtonItem
    UIBarButtonItem *SettingsBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_setting.png"] style:UIBarButtonItemStylePlain
                                   target:self
                                   action:@selector(ActionMethod:)];
    [buttons addObject:SettingsBtn];
    [SettingsBtn release];

    // put the buttons in the toolbar and release them
    [toolbar setItems:buttons animated:NO];
    [buttons release];

    // place the toolbar into the navigation bar
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
                                              initWithCustomView:toolbar]autorelease];
    [toolbar release];
于 2011-10-31T12:11:21.963 に答える