Скрыть панель вкладок, когда камера открыта - PullRequest
1 голос
/ 23 июля 2011

Все, с кем я работаю в приложении на основе вкладок.Я открываю камеру на экране, чтобы сфотографировать.Но когда камера открыта, я не вижу кнопку «Сделать фото» внизу.Я предполагаю, что кнопка скрывается за панелью вкладок.Если я прав, то мне нужно убрать панель вкладок на экране камеры.Может кто-нибудь сказать мне, как я могу удалить панель вкладок на экране камеры?

Я использую это для отображения камеры:

[self presentModalViewController:imagePickerController animated:YES];

Мое приложение на основе вкладок и этот кодзаписывается в контроллере представления, который связан с элементом панели вкладок.

if (!imagePickerController) {
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;

// If our device has a camera, we want to take a picture, otherwise, we just pick from
// photo library
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
}else
{
    [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention" message:@"Your device does not support taking photos from camera. Redirecting you to Photos Library instead." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}

// image picker needs a delegate so we can respond to its messages
imagePickerController.delegate = self;
}
// Place image picker on the screen
[self presentModalViewController:imagePickerController animated:YES];

Ответы [ 4 ]

4 голосов
/ 23 июля 2011

Представить контроллер средства выбора изображений из контроллера панели вкладок вместо контроллера представления, который он содержит.Другими словами:

[self.tabBarController presentModalViewController:imagePickerController animated:YES];
2 голосов
/ 23 июля 2011

попробуйте это:

[[[[UIApplication sharedApplication].delegate window] rootViewController] presentModalViewController:picker animated:YES];
0 голосов
/ 23 июля 2011

Установите полный размер кадра для модального вида, чтобы он покрывал весь экран - Размеры ~ (0,0,320,460)

imagePicker.view.frame = CGRectMake (0,0,320,460);
0 голосов
/ 23 июля 2011
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    imagePickerController.delegate = self;
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please choose the category you want your picture to be uploaded in." delegate:self cancelButtonTitle:@"General" otherButtonTitles:@"Fresh Cuts", nil];
    [alert show];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if (buttonIndex == 0)   //general
    {
        selected_category = 0;
    }
    else                    // fresh cuts
    {
        selected_category = 1;
    }
}


-(IBAction) uploadFromCameraButtonPressed{
    if (!imagePickerController) {
        imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self;

        // If our device has a camera, we want to take a picture, otherwise, we just pick from
        // photo library
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
        }else
        {
            [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention" message:@"Your device does not support taking photos from camera. Redirecting you to Photos Library instead." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }

        // image picker needs a delegate so we can respond to its messages
        imagePickerController.delegate = self;
    }

    [self presentModalViewController:imagePickerController animated:NO];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSData *imageData = UIImagePNGRepresentation(image);
    NSString *userName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_email"];

    NSMutableString *imageName = [[[NSMutableString alloc] initWithCapacity:0] autorelease];

    CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
    if (theUUID) {
        [imageName appendString:NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID))];
        CFRelease(theUUID);
    }
    [imageName appendString:@".png"];

    StatusBO *statusObj = [PhotoBO uploadImageFile:userName imageData:imageData file_name:imageName c_id:self.selected_category];

    if(statusObj.errorOccured == YES){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:statusObj.errorTitle message:statusObj.errorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
    }else{
    //  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:statusObj.errorTitle message:statusObj.errorMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        //[alertView show];
        [self dismissModalViewControllerAnimated:NO];
    }
}


-(IBAction) uploadFromFileButtonPressed{
    imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.delegate = self;
    [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [self presentModalViewController:imagePickerController animated:YES];
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-(IBAction) backButtonPressed{
    [self.view removeFromSuperview];
}

-(IBAction) takePhotoFromCamra{

}


- (void)dealloc {
    [super dealloc];
}


@end
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...