2013-10-09 30 views
1

我有一個UIImagePickerController作爲模式在iOS 7的UIPopoverController中呈現。當它出現時,我看不到任何取消按鈕。我試圖在其導航欄中插入leftBarItem:iOS 7設置UIImagePickerController leftBarItem

picker.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismissModalViewControllerAnimated:)]; 

但它不起作用。

這裏是我提出的選擇器:

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { 
    [picker.navigationBar setTranslucent:NO]; 
    [picker.navigationBar setBarStyle:UIBarStyleBlackOpaque]; 
    [picker.navigationBar setBarTintColor:barGray];   
}else{ 
    [picker.navigationController.navigationBar setTintColor:barGray]; 
} 
[self presentViewController:picker animated:YES completion:^{ 
    //I also tried to put the leftBarItem setting code here. Doesn't work either. 
}]; 

任何人有任何想法?

+0

我敢打賭'navigationItem'在那個點上是'nil'。 – Kevin

+0

它是。但爲什麼? – randomor

+0

其實'navigationItem'不是零,但'leftBarButtonItem'可以設置,但顯然不是正確的viewcontroller。 – randomor

回答

0

我可以使用UINavigationController委託方法設置leftBarButtonItem。原來picker.navigationItem不會削減它,因爲它不會在其自己的導航控制器中的根視圖控制器

相關問題