2

나는 '나는 버튼 대상에 다음과 같이 코딩을 쓸 때 그래서, 원,이 세 가지가 다른 클래스는UIIavageController에 UIImagePickerController 푸시하는 방법?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 

    myList = [[List alloc] init]; 
    mySettings = [[Settings alloc] init]; 
    myCriteria = [[Criteria alloc] initWithStyle:UITableViewStyleGrouped]; 

    first = [[UINavigationController alloc] initWithRootViewController:myList]; 
    second = [[UINavigationController alloc] initWithRootViewController:mySettings]; 
    third = [[UINavigationController alloc] initWithRootViewController:myCriteria]; 

    myTabBar = [[UITabBarController alloc] init]; 

    myTabBar.view.frame = CGRectMake(0,20,320,460); 


    UITabBarItem *first1 = [[UITabBarItem alloc] initWithTitle:@"List" image:[UIImage imageNamed:@"list.png"] tag:0]; 
    UITabBarItem *second2 = [[UITabBarItem alloc] initWithTitle:@"My Profile" image:[UIImage imageNamed:@"settings.png"] tag:1]; 
    UITabBarItem *third3 = [[UITabBarItem alloc] initWithTitle:@"Criteria" image:[UIImage imageNamed:@"Criteria.png"] tag:2]; 


    UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:myTabBar]; 

    first.tabBarItem = first1; 
    second.tabBarItem = second2; 
    third.tabBarItem = third3; 

    myControllerArray = [[NSArray alloc] initWithObjects:first, second, third, nil]; 

    [myTabBar setViewControllers:myControllerArray]; 
    [myTabBar setCustomizableViewControllers:myControllerArray]; 

    [self.window addSubview:myTabBar.view]; 

    // Add the view controller's view to the window and display. 
    // [self.window addSubview:viewController.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

가, 지금은 카메라와 앨범을 사용하려면 AppDelegate에에, 내 프로그램에 코딩을 다음 한 t 작업

- (void) useCamera 
{ 

    if ([UIImagePickerController isSourceTypeAvailable: 
     UIImagePickerControllerSourceTypeCamera]) 
    { 
     NSLog(@"If is true"); 
     UIImagePickerController *imagePicker = 
     [[UIImagePickerController alloc] init]; 

    // [self.navigationController pushViewController:imagePicker animated:YES]; 

     imagePicker.delegate = self; 
     imagePicker.sourceType = 
     UIImagePickerControllerSourceTypeCamera; 
     imagePicker.mediaTypes = [NSArray arrayWithObjects: 
            (NSString *) kUTTypeImage, 
            nil]; 
     imagePicker.allowsEditing = NO; 

     [self.tabBarController setCustomizableViewControllers:[[NSArray alloc]initWithObjects:imagePicker,self,nil]]; 
     [self.tabBarController setViewControllers:[[NSArray alloc]initWithObjects:imagePicker,self,nil]]; 

     //[self presentModalViewController:imagePicker animated:YES]; I tried 

     //[self.view addSubview:imagePicker.view]; I tried 
     //self.view=imagePicker.view; I tried 


     //[myScrollView addSubview:imagePicker]; I tried 
     //[myView addSubview:imagePicker]; I tried 

     [imagePicker release]; 

     newMedia = YES; 
    } 
} 
나는 위의 모든 방법을 시도했지만 그들이 일하고 UIImagePickerController를 보여주는되지

,

어떻게해야 지금 무엇을

,

내 질문에 명확하지 않은 사람이 다시 물어볼 수 있다면 .....

+0

navigationControllers 중 하나를 통해 imagePicker를 표시하려고 했습니까? – visakh7

+0

[self.navigationController pushViewController : imagePicker animated : YES]; 나는 이것을 했지, 이것에 대해 이야기하고 있니?나는 예, imagePickerviewControllerDelegate 여부 –

+0

이 시도 presentModalViewController – visakh7

답변

2

무엇 또한

[self.view addSubview:imagePicker.cameraOverlayView]에 대해, 당신은 당신의 self.view에 다른보기를 추가하는 시도가? 나는 imagePicker가 추가되고 있는지 궁금하지만, 추가하려는 뷰가 표시되지 않기 때문에로드되지 않습니다.

+1

imagePicker.cameraOverlayView 대신 imagePicker.view를 사용하면 시뮬레이터와 같이 카메라가없는 경우에도 작동합니다. –

1

네비게이션 컨트롤러 중 하나를 통해 imagePicker를 표시하려고 했습니까? 새로운 뷰 컨트롤러로 구성된 화상 선택기 컨트롤러를 통과 현재 활성 뷰 컨트롤러 presentModalViewController:animated: 메소드를 호출하여 현재

사용자 인터페이스 Reference 가입일

. iPad에서는 initWithContentViewController:에 설명 된 팝업을 사용하여 사용자 인터페이스를 표시하고 UIPopoverController 클래스 참조에있는 "Popover 제시 및 해제"를 사용할 수 있습니다.

+0

@ 2KV7, xcode에서 코딩 해보십시오. 제안 된 답변에 문제가있는 것을 볼 수 있습니다 ... –

+0

현재 활성보기 컨트롤러는 무엇입니까? useCamera를 호출하는 것? – visakh7

+0

그것은 TabBarItem에 두 번째입니다, 그리고 그냥 버튼을 클릭하고 카메라 소스의 UIImagePickerController로 나를 데려 갈 방법을 호출하지만 그것은 최대 개까지 걸리지 않습니다 –

0

tabBarController (UITabBarController UIViewController에서 상속)를 통해 UIImagePickerController를 표시하려고 했습니까? AppDelegate에 대한 싱글 톤을 만들고 그 tabBarController가 AppController의 속성이라고 가정하면 (아래 싱글 톤에 대한 샘플 코드를 추가 한 편의상)

AppController와 같은 모양이됩니다. 에 시간

#import <UIKit/UIKit.h> 

@interface AppController : NSObject <UIApplicationDelegate> { 
    UITabBarController *tabBarController; 
} 
// Class methods for convenience 
+ (AppController *)sharedAppController; 

// *** Properties 
@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) UITabBarController *tabBarController; 

@end 

AppController.m 클래스에서 이제

#import "AppController.h" 

static AppController *sharedInstance; 

@implementation AppController 

@synthesize window=_window; 
@synthesize tabBarController; 

#pragma mark - Initialization 
- (id)init 
{ 
    // Create the sharedInstance of the application 
    if (sharedInstance) { 
    NSLog(@"Error: You are creating a second AppController"); 
    } 
    [super init]; 
    sharedInstance = self; 

    return self; 
} 

+ (AppController *)sharedAppController 
{ 
    return sharedInstance; 
} 

- (void)dealloc 
{ 
    [_window release]; 
    [tabBarController release]; 
    [super dealloc]; 
} 

, useCamera 방법은이 작업을 수행하여 imagePicker 전화 :

- (void)useCamera 
{ 
    // YOUR CODE ... 

    // Place image picker 
    [[[AppController sharedAppController] tabBarController] 
    presentModalViewController:imagePicker animated:YES]; 

    // YOUR RELEASE CODE ... 
} 

행운과 행복 코딩!

0

경우 GKImagePicker 사용 :

[self.view의 addSubview : self.imagePicker.imagePickerController.view];

관련 문제