Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 加载视图未显示期间添加的UIToolBar项_Iphone - Fatal编程技术网

Iphone 加载视图未显示期间添加的UIToolBar项

Iphone 加载视图未显示期间添加的UIToolBar项,iphone,Iphone,我有一个UIViewController,它是通过编程方式创建的。我在loadView中包含以下代码。显示了工具栏,但没有显示我添加的按钮。任何帮助都将不胜感激 [self.navigationController setToolbarHidden:NO animated:NO]; UIBarButtonItem *actionB = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAc

我有一个UIViewController,它是通过编程方式创建的。我在loadView中包含以下代码。显示了工具栏,但没有显示我添加的按钮。任何帮助都将不胜感激

[self.navigationController setToolbarHidden:NO animated:NO];

    UIBarButtonItem *actionB = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionBTapped:)];
    [self.navigationController.toolbar setItems:[NSArray arrayWithObject:actionB] animated:NO];
    [actionB release];
试试这个:

NSMutableArray *items = [[[NSMutableArray alloc] init] autorelease];
UIBarButtonItem *labelButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil] autorelease];
[items addObject:labelButton];
[items addObject:[[[UIBarButtonItem alloc] initWithTitle:@"YoutTitle" style:UIBarButtonItemStyleDone target:self action:@selector(actionBTapped:)] autorelease]];
[self.navigationController.toolbar setItems:items animated:NO];
试试这个:

NSMutableArray *items = [[[NSMutableArray alloc] init] autorelease];
UIBarButtonItem *labelButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil] autorelease];
[items addObject:labelButton];
[items addObject:[[[UIBarButtonItem alloc] initWithTitle:@"YoutTitle" style:UIBarButtonItemStyleDone target:self action:@selector(actionBTapped:)] autorelease]];
[self.navigationController.toolbar setItems:items animated:NO];

要在UIViewController本身而不是其导航控制器上设置项目:

self.toolbarItems = [NSArray arrayWithObject:actionB];

要在UIViewController本身而不是其导航控制器上设置项目:

self.toolbarItems = [NSArray arrayWithObject:actionB];