目前我正在開發多語言應用程序,並且想要更改UIImagePickerController
的Cancel
,Use
和Retake
按鈕標題。我怎樣才能做到這一點?如何更改UIImagePickerController中的取消按鈕標題?
2
A
回答
3
我的問題是通過使用自定義覆蓋類解決。
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;
// Insert the overlay
self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
self.overlay.pickerReference = self.picker;
self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;
[self presentModalViewController:self.picker animated:NO];
1
它會自動更改爲設備語言。
你不需要擔心這一點。你也不能改變它的行爲。
控件像:MFMessageComposer
,MFMailComposer
,UIImagePicker
等將自動將其默認控件文本更改爲設備語言。
+0
如果設備語言是英語,我想在那個時候改變標題,我們如何實現這一目標? – Balu 2013-05-08 09:13:55
+0
@孫:不可能。 – 2013-05-08 09:30:55
1
指派代表作爲自我的imagepicker控制器並添加以下代碼:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
UINavigationItem *ipcNavBarTopItem;
// add done button to right side of nav bar
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@\"Done\"
style:UIBarButtonItemStylePlain
target:self
action:@selector(saveImages:)];
UINavigationBar *bar = navigationController.navigationBar;
[bar setHidden:NO];
ipcNavBarTopItem = bar.topItem;
ipcNavBarTopItem.title = @\"Pick Images\";
ipcNavBarTopItem.rightBarButtonItem = doneButton;
}
3
只需添加所需的本地化項目中的:
1)選擇工程文件;
2)在「項目和目標」列表中選擇您的項目;
3)選擇「信息」(在屏幕頂部);
4)在「本地化」部分添加所需的語言。
-1
只要找到和UIButton的
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
for (UIView *v in viewController.view.subviews)
{
if ([v isKindOfClass:[NSClassFromString(@"CMKBottomBar") class]])
{
SEL se = NSSelectorFromString(@"cancelButton");
if ([v respondsToSelector:se])
{
UIButton *cancelButton = [v performSelector:se];
[cancelButton setTitle:@"New title" forState:UIControlStateNormal];
}
}
}
}
0
的變化文本這一切都是一堆垃圾。只有好的解決方案在這裏...
//this is your camera method
- (void)startCameraControllerUsingDelegate:(id<UIImagePickerControllerDelegate, UINavigationControllerDelegate>)delegate gallery:(BOOL)openGallery
{
if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil))
return;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
if (openGallery) {
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
} else {
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
}
cameraUI.allowsEditing = YES;
//set your delegate type UINavigationControllerDelegate here! It will trigger function bellow!
cameraUI.delegate = delegate;
[self presentViewController:cameraUI animated:YES completion:nil];
}
//UINavigationControllerDelegate function
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
//this is where magic happends! This leaves button empty and it will not ruin title center position!... or give it your desired string
viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
相關問題
- 1. 在UIImagePickerController的導航欄中更改欄按鈕的標題
- 2. Swift:searchBar - 如何更改「取消」按鈕標題
- 3. 無法更改UISearchBar中的取消按鈕的標題
- 4. 刪除UIImagePickerController中的取消按鈕?
- 5. iOS7 UIImagePickerController取消按鈕消失
- 6. 如何更改Iphone sdk中的搜索欄取消按鈕的標題?
- 7. 按下按鈕B時如何更改按鈕A的標題?
- 8. 如何動畫更改按鈕標題?
- 9. 如何更改自定義頁面上的下一步/取消按鈕標題?
- 10. 在UIImagePickerController取消按鈕不顯示?
- 11. 如何更改Primefaces文件上傳取消按鈕圖標
- 12. Swift:如何更改UIImagePickerController中的按鈕文本?
- 13. 更改Lotus Notes中按鈕的標題
- 14. 快速更改按鈕標題後的後退按鈕標題
- 15. 使用的UIImagePickerController問題取消按鈕不工作
- 16. 更改文字後,無法更改UISearchBar取消按鈕標題顏色。
- 17. ios UIImagePickerController拍照按鈕標題
- 18. 如何更改Swift 3中UISearchBar「取消」按鈕的顏色?
- 19. 如何更改iOS7中UISearchBar的取消按鈕色調顏色
- 20. 如何更改UISearchBar中取消按鈕的顏色
- 21. 更改導航欄UIImagePickerController的標題
- 22. 如何更改UIImagePickerController導航欄上的按鈕顏色?
- 23. 按鈕每次按下更改標題
- 24. 更改按鈕標題問題
- 25. Swift:如何更改UIImagePickerController中的按鈕「使用照片」,「取消」,「拍攝」,「重拍」的默認行爲
- 26. 如何在TableView中更改按鈕的標題(Swift)
- 27. UIImagePickerController在iOS7中取消按鈕的彈出式窗口中
- 28. 每次在Xcode 4.3中點擊按鈕時,如何更改按鈕的標題?
- 29. 如何更改UITabBarController更多按鈕的標題?
- 30. 更改HTML按鈕的標題
GUD解決方案親愛的... – Romance 2013-05-08 12:16:21