Search code examples
iosobjective-cios5uiimagepickercontrollerphotolibrary

I want means, add UIToolbar on UIImagePickerController of SourceType PhotoLibrary


I want means, add UIToolbar on UIImagePickerController of SourceType PhotoLibrary.

I tried use:

[UIViewController presentViewController:UIImagePickerController completion:^{}];

One time was like successfully. But, PhotoLibrary's UINavigation Back button use then UIToolbar is hidden.

Please, how means or References, Documents, others.

I tried use presentViewController: completion: block.

- (void)showPhotoLibrary {

    if ( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] ) {
        return;
    }

    UIImagePickerController* ipc = [[UIImagePickerController alloc] init];
    [ipc setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [ipc setDelegate:self];

    [self presentViewController:ipc animated:YES completion:^{
        [ipc setToolbarHidden:NO];
    }];
}

Solution

  • Self resolved. thank you.

    - (void)showPhotoLibrary {
    
        if ( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] ) {
            return;
        }
    
        UIImagePickerController* ipc = [[UIImagePickerController alloc] init];
        [ipc setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        [ipc setDelegate:self];
    
        UIToolbar* tb = [[UIToolbar alloc] init];
        float tbh = 44.0f;
        float tbw = [[ipc view] frame].size.width;
        float tby = [[ipc view] frame].size.height - tbh;
        [tb setFrame:CGRectMake(0, tby, tbw, tbh)];
    
        [self presentViewController:ipc animated:YES completion:^{
            [[ipc view] addSubview:tb];
        }];
    }