Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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
Ios 以编程方式更改UINavigationBar上的UIBarButtonim标识符_Ios_Objective C_Ios7 - Fatal编程技术网

Ios 以编程方式更改UINavigationBar上的UIBarButtonim标识符

Ios 以编程方式更改UINavigationBar上的UIBarButtonim标识符,ios,objective-c,ios7,Ios,Objective C,Ios7,所以我只是使用一个普通的视图控制器。我将一个导航条拖到顶部,并添加了一个带有“暂停”标识符的UIBarButtonItem 我希望能够将该标识符更改为“播放”标识符 这可能吗?我找不到关于它的任何信息 我尝试创建一个新的,但不确定从那里去哪里 UIBarButtonItem *flipButton = [[UIBarButtonItem alloc] initWithTitle:@"Flip"

所以我只是使用一个普通的视图控制器。我将一个导航条拖到顶部,并添加了一个带有“暂停”标识符的UIBarButtonItem

我希望能够将该标识符更改为“播放”标识符

这可能吗?我找不到关于它的任何信息

我尝试创建一个新的,但不确定从那里去哪里

    UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
                              initWithTitle:@"Flip"
                              style:UIBarButtonItemStyleBordered
                              target:self
                              action:@selector(flipView)];

任何帮助都会很好。

您正在寻找
UIBarButtonSystemItemPlay
。只需设置它,指定您的选择器和目标,然后选择您想要的barButtonItem

 UIBarButtonItem *playButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(playButtonPressed:)];
 self.navigationItem.rightBarButtonItem = playButton;//Or leftBarButtonItem if you want it to be on the left

谢谢因此,当我尝试这样做时,我只是将导航栏拖到viewController上,它没有添加任何内容。有没有一种方法可以像self.navBar.rightbuttonItem一样呢?您可以创建一个引用出口,指向您放置在导航栏上的实际UIBarButtonItem,并直接分配给它。不过,只使用navigationController更容易(特别是因为您必须在iOS 7中说明状态栏)