Draw a cross at center of a UIImagePickerController - iphone

I'm very new on iPhone development. I'm trying to draw a cross over the image obtained from camera.
I'm using a custom ViewController that inherits from UIImagePickerController.
When I star the application, I see the cross, but a few seconds after the cross disappears.
Should I use cameraOverlayView?
Thank you

UIImagePickerController is not designed to be subclassed. Do so at your own risk.
In OS 3.1, cameraOverlayView is the approved way of drawing over the camera view. Note that if you set an overlay view, the autofocus controls no longer seem to work.
EDIT: Turns out I'm just paraphrasing the docs:
Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. In iPhone OS 3.1 and later, you can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

Related

Rotating camera view on iOS

I've read few questions here on stack and I'm in a dead-end. I want to have device (iPhone/iPad) camera as a background, to one of my ViewControllers. I'm using Storyboard and UINavigationsViewController, so I'm modyfing a child ViewController. As far as I read, this means that I cannot force this "child" to start in specific orientation (first problem).
Secondly, I decided to go with UIImagePickerController, but as I got it right - you cannot rotate this component, right?
So basically my question is where to go from here, to achieve camera view on background no matter what device orientation? It surely can be done, because Vuforia i.e. has it (and they are using UIImagePickerController with EAGLView).
You have two options to do that task:
1) You can use Eaglview to render the frames of camera device in background.
2) You can use caeagllayer to do the same.
To draw on that layer you have to use drawableproperties and CaTransformationMatrix

How can I place a UILabel within an OpenGL ES 2.0 application?

I have an OpenGL ES 2.0 application for iPad. Is it possible to place text on the screen using a UILabel, like you can in a traditional iOS application?
I tried inserting a label, but it didn't show up. If it is possible, can someone explain the process? Should we insert the label in the viewcontroller.xib file or the mainwindow.xib file, and also where must the appropriate code be written?
As I explain in my similar answers here and here, your OpenGL ES content is hosted within a CAEAGLLayer that backs a particular UIView. This UIView behaves like any other view in the display hierarchy, so you can add UILabels and other controls on top of it or as siblings that overlay this view.
If you are using Interface Builder to lay out your UI, you should have a view that contains your OpenGL ES content somewhere in that interface. You can add the UILabel as a subview of this UIView in Interface Builder and have it show (remember to color the text appropriately so that you don't get black text on a black OpenGL ES background). You can also do this programmatically by using -addSubview: on your OpenGL ES hosting view.
In my tests, overlaying UIKit controls on OpenGL ES content only leads to a slight reduction in rendering speed (from 1-5% in my applications), so this is a viable approach.
If you want to see an example of this in action, look at the source code for my Molecules application, which uses labels and other controls overlaid on the OpenGL ES content on the iPhone.
Only do that if the labels go on top of the OpenGL content. UIKit elements sometimes do not mix well with OpenGL elements. Blending OpenGL content with transparency on top of UIKit elements is really slow. In these cases, it's better to add the label in your OpenGL code. Static text is very easy, just draw a flat object facing the camera and with a texture image of your text. Dynamic text would require more work to adjust the texture with the font to show the correct text.
To do this, add the label to to viewcontroller.xib file, not the mainwindow.xib file. The appropriate code for controlling the UILabel would go in the view controller's .h and .m files. In the standard Xcode iOS OpenGL ES Application template the main view controller's .xib file will contain one EAGLView view. The label can be added to that view, and connected to an IBOutlet in the view controller's .h file.

iPhone: how to work with augmented reality

In augmented reality app,on Camera view another transparent view will be, On this transparent view, we used for drawing on camera view and saving it, can you suggest (Start and end) me how to work with this application,
thanks you, have a great day
You'll want to use a UIImagePickerController to show the camera preview. Set its showsCameraControls property to no, so none of the standard photo-taking interface is visible. Now, UIImagePickerControllers have a nice little cameraOverlayView property that you can use to place any view you want over the camera preview. Depending on what precisely you want to augment your reality with, this view could be realized in different ways. For example, if you want to overlay 3D models over the camera preview, this view could be a transparent OpenGL ES context. If you don't need any 3D assets, it can be a regular transparent UIView on which you draw some custom graphics with Quartz. It's up to you, but you want the general pattern of:
UIImagePickerController with showsCameraControls = NO
set cameraOverlayView to some transparent view to render content
This is really a huge question, and there are tons of intricacies depending on the specifics of your design. This is just a general summary.

Iphone sdk custom uiview orientation issue

I am using custom based uiview controller with uitabbar contains uitableview. I am using image for cell background. I want to do orientation from portrait to landscape but the issue is it is not changing on orientation. I just want to know is there are any special thing for custom uiviewcontroller for orientation?
Thanks in advance
Regards,
sathish
If nothing happens when you rotate the device, you either have the system-wide rotation lock enabled (you checked that, right?), or your view controller isn't returning YES to the alternate orientation in its shouldAutorotateToInterfaceOrientation:, or you're doing something odd with your views that means your view controller isn't getting set as the “frontmost” one and thus isn't getting asked about orientation changes. It'll be easier to narrow that down if you post the code you're using to set up the controller and its view.

iPhone autorotation only on specific screens in under a navigation controller

This is just an example of the basic problem I'm having, so don't worry if this situation sounds a bit pointless ;)
Let's say I have an app that's mainly a UINavigationController just two levels deep. The top level is a table with a list of image filenames, and the second level has just a UIImageView showing the image for the filename you tapped.
For an app such as this, does anyone know a good way to allow the table at the top level to autorotate while keeping the second level of images fixed in portrait mode?
So far I've been able to almost get there... but when I tap a filename while in landscape mode, the image slides into view in the wrong orientation even if the second level view controller's shouldAutorotateToInterfaceOrientation returns yes for only portrait modes.
There was no good way to do this in iPhone OS 2.x, but in 3.0, they've dramatically improved it.
In 2.x, the shouldAutorotateToInterfaceOrientation: delegate method was only obeyed for changes to the orientation, so you'd get the behavior you describe: if it was rotated in another view controller, it would stay rotated through pushes and pops even if the new view controller didn't support rotation to that orientation.
In 3.0, UINavigationController polls shouldAutorotateToInterfaceOrientation: on each push or pop and obeys what it returns the way you'd expect, e.g.: if you're currently rotated in Landscape Left orientation, and you push an instance of a view controller that only supports Portrait orientation via shouldAutorotateToInterfaceOrientation:, it automatically and instantly flips the logical orientation and slides in the new view the correct way in Portrait orientation.
Note that this will only work on applications linked against (and therefore requiring) 3.0. For applications linked against 2.x, it will emulate the old behavior.
The problem is that if you use auto rotation the entire UI (including the UIWindow instance I believe) is rotated.
Anything pushed onto the navigation controller at this point will be done in landscape.
So when you push the imageview, that is exactly what you get.
To get this to work, you have to either:
Handle the rotation of the root view
manually (using a transform)
Unrotate the image view by -PI/2
using a transform.
Either way you have to perform the transforms manually to get this to work.
As a side note, this may be bad UI design. As a user, I would expect as I drill down for images to appear rightside up. But this is without knowing the exact context of your app.