I am trying to make graphics move randomly in cameraview. Is there any way that I can get the balls moving in camera view? Or any tutorials that any one of you may refer me to?
To do so, you will need to implement your own camera view: make UIViewController class, set UIImagePicerControllerSelegate to it, implement all necessary methods to make imagePicker work, set useCustomInterface property to "NO" and then, add any sub views to your custom camera. You may also make them move as you like.
In 5 words, implement your own custom camera.
Here is poplar question about what you need: iPhone: Camera Preview Overlay
Related
Language: Swift, IDE: Xcode for iOS development, Single View Application > View Controller...
I have 2 UIImage Views with identical images that I'm scroll-animating from left to right across the view in order to create a 'slowly-moving background' of sorts. I'd like to place other UI elements (Labels, other images, etc.) in the foreground of this repeating background animation, but find when I run the simulator the foreground image isn't seen...
Question: Is it possible to force other UI elements to stay in front of a repeating animation programmatically?
I'm not at my Mac so I can't share my code at the moment, but if you know a straight answer to the question and/or which method could best achieve this, I'm all ears!!
Thanks in advance! :)
This depends on the z-ordering of the views. Assuming you are adding all of your views then starting the animation call bringSubViewToFront on the view you are animating right before you start animating it. If you are laying things out in interface builder the Z order is based on top = farthest and bottom = closest. If you are adding view programmatically the newest view is always added in front. You can change this with insertSubview:at: and the related methods. Take a look at the documentation for UIView.
If you want z-index use:
YourImageViewName.layer.zPosition = 1
Also you could play with bringToFront method on the parent view:
self.view.bringSubviewToFront(YourImageViewName)
Hope this fix your problem.
I've written a small multiplayer game for the iphone. Once one of the players win, I want to display him 'You Win' image and a button so that he can play again.
How can this be done? One option is to use a segue to a new view-controller, but I think this should be shown with the game in the background. What would you suggest, as I'm pretty sure this is a common scenario for an iphone game/app.
EDIT: I ended up using both Phillip Mills's answer and Selkie's answer. Here is on How to Use UIView transitionWithView?
You can create the custom view and keep it as a separate property within your main game view controller. When someone wins, add it as a subview to the view property of the controller. It can be full screen size with transparency so that it's effectively modal, yet shows the game as background.
You can make it as a view, then show it using UIView animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
The animation block could be sliding up, fading or whatever you want.
The other way is to add it at the beginning, but set its hidden property as YES. Change it to NO when it's needed.
I've got a question about the Model View Controller (MVC) design pattern for iphone games.
Let's say I have a simple game that uses a ViewController. So this view controller has an associated window/view and takes player inputs of buttons sliders, etc.. on this view.
Now I also have a subview of the ViewController's main window/view and I actually do some animation of various polygons in this subview. I also want to take touch events in this subview.
My question is, in the subview, I've got all the user touch code and animation code as the player's touch input affects the animation directly changing rotation etc.. There's a lot of variables in my subview class.
Am I violating the MVC design? Should I delegate this stuff to another class or the view controller?
Many thanks
It depends on what you're trying to accomplish.
Let's assume you want your game to run on an ordinary PC, as well as the iPhone.
Obviously, you'd want to isolate all of the code specific to the iPhone, which includes the touches. I'm assuming you'd want the animation on both versions of your game, so that would be part of the controller, or perhaps the model. Rendering the animation would be part of the view.
The easiest way to determine which functions belong in the view, and which functions belong in the controller, is to imagine porting your application to two different viewers. It doesn't have to be a PC and an iPhone. It can be Android and an iPhone. :-)
I'm trying to make an augmented reality application with a waypoint structure, like Yelp, and I'm wondering how to set up my main view so that it displays the camera view on the whole screen. I've heard of using the UIImagePickerController Class, but I'm unsure how to manipulate the code so that it doesn't actually take a picture, but just stays in the view mode. Any help would be appreciated, thanks!
From the documentation:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
You should just be able to create a UIImagePickerController and set sourceType to UIImagePickerControllerSourceTypeCamera, and then disable the camera controls using showsCameraControls.
I would like to put thumbnails in the toolbar like the Photos app. Like the screenshot on the left:
(source: apple.com)
Is there is a built-in control to do this, or do I have to implement it from scratch?
If the answer is from scratch, any tips?
This would be a control you'd have to write yourself. I'm not what the best approach would be, but I think I'd go with subclassing a UISlider, drawing the array of images next to each other to create the track, and then using the current image as the handle.
From scratch, is the answer, unfortunately.
You create a custom view and add your array of images as subviews using UIImageView objects incrementing your x position by the the thumbnail width you've determined to use.
Then override the touch events for you custom view. Determine which image view the touch is currently over in -touchesMoved and use Core Animation to animate the current view's scale making it larger than the rest. Add the custom view to your toolbar wrapping your custom view in a UIBarButtonItem using -initWithCustomView.
Remember to enable user interaction on your custom view or you won't receive any touch events. If you need help with the code, update your question with some code specific questions.
Should anyone still need it, I made an effort of coming up with ThumbnailPickerView - a simple UI control resembling Photos.app thumbnail slider.