2013-05-08 100 views

回答

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]; 
+0

GUD解決方案親愛的... – Romance 2013-05-08 12:16:21

1

它會自動更改爲設備語言。

你不需要擔心這一點。你也不能改變它的行爲。

控件像:MFMessageComposerMFMailComposer,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]; 
} 
相關問題