-(void) showChooseMyPic
{
CGSize winSize = [[CCDirector sharedDirector] winSize];
if (m_ImagePickerController == nil) {
// 画像選択画面の初期化
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([UIImagePickerController isSourceTypeAvailable:sourceType]) {
m_ImagePickerController = [[UIImagePickerController alloc] init];
m_ImagePickerController.delegate = self;
m_ImagePickerController.sourceType = sourceType;
m_ImagePickerController.wantsFullScreenLayout = YES;
m_UIPopoverController = [[UIPopoverController alloc] initWithContentViewController:m_ImagePickerController];
m_UIPopoverController.delegate = self;
[m_UIPopoverController setPopoverContentSize:winSize animated:NO];
}
}
// 表示
CGRect r = CGRectMake(20,20,10,10);
r.origin = [[CCDirector sharedDirector] convertToGL:r.origin];
[m_UIPopoverController presentPopoverFromRect:r inView:[[CCDirector sharedDirector] openGLView] permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
// 画像選択キャンセル
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
// PickerControll周りの解放を行なう
[self releasePicker];
}
//画像選択ポップアップの外側をタップし、画像選択画面を抜けた場合
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
// PickerControll周りの解放を行なう
[self releasePicker];
}
// PickerController周りの解放
-(void) releasePicker
{
[m_ImagePickerController dismissModalViewControllerAnimated:YES];
[m_ImagePickerController.view removeFromSuperview];
[m_ImagePickerController release];
m_ImagePickerController = nil;
[m_UIPopoverController dismissPopoverAnimated:YES];
[m_UIPopoverController release];
m_UIPopoverController = nil;
}
コメントする