在 UIImagePickerController 之后显示 UIViewController
我知道这是 iPhone 编程的热门问题,但我还找不到好的答案。
我有一个基于 UITabBarController
的应用程序,中间的 tabBarItem
覆盖有自定义按钮。此自定义按钮用于发布新项目。就像这个(我使用Instagram,例如)。
当然,这个按钮必须在整个应用程序中都可以访问。 当您单击此按钮时,您将看到一个 UIImagePickerController,用于从库或相机中选择图像。
问题是如何在选择图像后显示另一个 UIViewController
。
第一种方法是从 UIImagePickerController
委托方法设置一个布尔变量,并重写 all 视图控制器的 viewDidAppear
方法来检查布尔变量,如果它是TRUE
,调用[self.tabBarController PresentModalViewController:MyControlleranimated:YES]
。但我觉得这个实在是太丑了。
你还有其他(优雅的)方法吗?
I know this is a hot question for iPhone programming but I can't find a good answer yet.
I've an UITabBarController
based application with the middle tabBarItem
overlayed by a custom button. This custom button is used for posting a new item. Like this (I take Instagram, for example).
Of course this button must be accessible in the whole application.
When you click on this button you'll can see an UIImagePickerController for choosing an image from your library or from the camera.
The problem is how to display another UIViewController
after you've chosen the image.
The first method is set a boolean variable from the UIImagePickerController
delegate method and override the viewDidAppear
method of all view controllers for checking the boolean var and if it's TRUE
, call [self.tabBarController presentModalViewController:MyController animated:YES]
. But I think this one is pretty ugly.
Have you others (elegant) method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个新的 UIImagePickerControllerDelegate 对象,捕获用户操作,并呈现模式视图控制器或向视图控制器发送消息来处理它。
Create a new
UIImagePickerControllerDelegate
object, trap user actions, and either present a modal view controller or send a message to a view controller to handle it.假设
ViewController A
是您单击启动UIImagePickerController
的相机按钮的类。ViewController A
应该是UIImagePickerController
的委托。然后,在 ViewController A 类中,我们定义单击“使用”按钮时调用的函数。
Let's say
ViewController A
is the class where you click on the camera button startingUIImagePickerController
.ViewController A
should be the delegate ofUIImagePickerController
.Then, in
ViewController A
class, we define the function which is called when you click on the button Use.