imagepicker+navigationController 在 iphone 中导致问题?

发布于 2024-08-05 07:40:48 字数 1766 浏览 1 评论 0原文

我该怎么做..我有应用程序委托...我在其中通过代码添加了导航控制器...

这是我的代码...

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
HomeScreenController  *homeScreenobj=[[HomeScreenController alloc] initWithNibName:@"HomeScreen" bundle:[NSBundle mainBundle]];
navController = [[UINavigationController alloc] initWithRootViewController:homeScreenobj]; 
[homeScreenobj release];  
   [window addSubview:navController.view];

// Override point for customization after app launch    
 [window makeKeyAndVisible];
}

在主屏幕上我有一个带有三个按钮的选项卡栏,这是一个图像

替代文字

我想从 imagepickerController 的库中拍摄照片...但是出现奇怪的问题,

它被添加到主窗口中,我不知道为什么

这里有一个图像

alt text

为什么不全屏显示。 ...而且如果我把这行

imagePickerController.allowsImageEditing = YES;

它挂起不知道为什么..这是我拍摄照片的代码....

-(IBAction)TakePhotoClicked
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsImageEditing = YES;
imagePickerController.delegate = self;
imagePickerController.sourceType = 
UIImagePickerControllerSourceTypePhotoLibrary;
//self.navigationController.navigationBar.hidden=YES;
[self.navigationController pushViewController:imagePickerController animated:NO];
//[imagePickerController release];
}

如果我不评论这一行 //self.navigationController.navigationBar.hidden=YES;

它显示如下

alt text

点击主页按钮返回主页...

how do i do this..i have appliation delegate...in which i added uinavigation controller through code...

here is my code...

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
HomeScreenController  *homeScreenobj=[[HomeScreenController alloc] initWithNibName:@"HomeScreen" bundle:[NSBundle mainBundle]];
navController = [[UINavigationController alloc] initWithRootViewController:homeScreenobj]; 
[homeScreenobj release];  
   [window addSubview:navController.view];

// Override point for customization after app launch    
 [window makeKeyAndVisible];
}

on homescreen i have a tabbar with three buttons here is an image

alt text

i want to take photo from library from imagepickerController...but getting weired issues

it is added to the main window i don't know why

here is an image for this

alt text

why this isn't shown fullscreen.... and also if i put this line

imagePickerController.allowsImageEditing = YES;

it hangs don't know why..here is my code to takePhoto....

-(IBAction)TakePhotoClicked
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsImageEditing = YES;
imagePickerController.delegate = self;
imagePickerController.sourceType = 
UIImagePickerControllerSourceTypePhotoLibrary;
//self.navigationController.navigationBar.hidden=YES;
[self.navigationController pushViewController:imagePickerController animated:NO];
//[imagePickerController release];
}

if i don't put this line to commented
//self.navigationController.navigationBar.hidden=YES;

it shows like this

alt text

where clicking on home button take back to home...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

御守 2024-08-12 07:40:48

您必须将 UIImagePickerController 呈现为模式视图控制器。因此,不要推送控制器,而是将其呈现为模式:

[self.navigationController presentModalViewController:imagePickerController animated:YES];

您可以使用 -[UINavigationController DismissModalViewControllerAnimated:] 弹出图像选择器,以返回到堆栈上的最后一个视图控制器。

You have to present the UIImagePickerController as a modal view controller. So don't push your controller, but present it as modal:

[self.navigationController presentModalViewController:imagePickerController animated:YES];

You can pop the image picker using -[UINavigationController dismissModalViewControllerAnimated:] to go back to the last view controller on the stack.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文