I want to be able to display an image on the iPhone when the device is shaken. I can play a sound but also want to pop up an image at the same time.
Any ideas on how to do this would be appreciated.
thx,
wes
How I would do it?
In your header file, define an UIImageView.
When your device is shaken, init the view with the right frame
Load an image in that UIImageView.
Add that UIImageView to the view that is currently shown.
Create a NSTimer which has an interval of the time you want to show your image
When the timer hits its interval, remove the imageview from the view.
I am not putting all kinds of code here, because you also supply no code whatsoever, but I think you can figure it out yourself.
Related
I want to hide animation that shows shutter opening while presenting UIImagePickerController to take picture. I checked this question for the same which contains the accepted but I was unable to replicate that functionality in my controller.
I gave overlayView as self.view and when I hide PLCameraView it shows blank white portion and than I am able to take picture. Is there any way to remove that white portion ?
IF needed I can post my full sourcecode project...
Can some body please highlight how to do this ?
Edit:
What I want to do is based on certain event and conditions I want to place image taken from camera or default image in db. And picture taking doesn't involve user interaction so I put NSTimer and take snapshot with the help of takePicture method.
Any thoughts ?
Instead of messing about with the view hierarchy of UIImagePickerController (which you are forcefully warned against in the docs) you should probably use AVCaptureSession and create your own ImagePicker to capture raw images from the video feed.
See http://developer.apple.com/library/ios/#samplecode/AVCam/Listings/Classes_AVCamCaptureManager_m.html for hints.
im new to iphone development.here i added some images to button in uiview programmaticaly in iphone. Here my problem is i want to add some more images in uiview. i added next and previous buttons in view .if click nextbutton some more will displayed in next view. i tried but i dont no how to displayed programmaticaly some more images when i click nextbutton in iphone.
can any one plz help me for my problem.
Thank you in advance.
Add a UIImageView to the view and then do:
myUIImageView.image = [UIImage imageNamed:#"anImageInMyBundle"];
Now, if you want to have a bunch of images and go through them systematically, you have a few options. This is going to depend on what your app actually does.
If you're displaying local images that are in your bundle, you can just create an NSArray (mutable or immutable - per the situation) and add all your UIImages to it at run time.
If your app downloads data from the web, you're probably going to start making network calls in a secondary thread that downloads and sets the next image. Give us a better idea of what your app does, and we might be able to provide more specific code/examples.
hi i am a new iphone programmer
i am creating a imagedisplay type application where i have to display images on a view and by presssing a next button a new image should appear on same view (i am using database)...
therefore i need to reload my current view again and again...each time when i click that button....
i tried some suggesion which are given on this website but not satisfied because many of them are based on timer...
please help.....
May be I have missed something in your question. But why you need to reload the entire view? You are using an UIImageView to display your image, right? And you are not showing any kind of scroll, but only a next button, right? Then why don't you just set the image property of UIImageView when the button is tapped.
// in button handler
myImageView.image = [UIImage imageNamed:#"new_image.png"];
Perhaps you could use a paged UIScrollView with three uIImageViews and always have the previous, current and next image loaded. This way when the user hits next, it scrolls animated to the next image. When page 3 is loaded, it programmatically sets the second image view as the desired next image, sets the image you came from on the first image view, and sets the scroll view non-animated to page two and loads the next image in the third image view.
Sounds complicated but basically you are giving the appearance of an infinite scroller but only pulling one image at a time except for initial load of three.
You could try looking at the "PageControl" Example Project in the XCode Documentation. It should give you a good starting point.
i have an uiscrollview and i add one by one uiimageviews but when i add more than 40 objects i have problem with memory i guess and the app crashes...what should i do? i am trying to make an app like photo viewer from apple! Help please!
i do not want thumbnais i just want to show the next image when the user flick from one to another but i have to unload the previous image and show the next one
i remove the previous like this
UIImageView l;
l=[[scroll subviews] objectAtIndex:0];
[l removeFromSuperview];
l=nil;
and then i add the next one like this
[scroll insertSubview:imageView atIndex:counter];
but i see a black background no image
please help!
The best way to do this is to load a few of the images at a time into a table view. In each cell of the table, put three thumbnails. You'll need to make a custom cell. That way, the table cells will be de-queued and the memory re-used. Check the Facebook Three20 project, I think they've implemented it like this, so you'll have some code to work with.
http://joehewitt.com/post/the-three20-project/
Ask yourself, do you really need to load all 100 images into memory? Why not just load a few images at a time in the background, depending on what image the user has scrolled to?
Don't do it that way.
If you want to display a 100 small thumbnails, resize them first with core graphics. Then they take up much less memory when you display 100 images at once.
If you want to display a 100 large images but only one is visible at a time, have 1 or 2 image views that load up the current and next images, and animate them in a clever way to make it look an endless stream. You can still use a scrollView, just monitor it's position and position your image views appropriately.
There is exactly an apple sample code that do what you want. Look for the PageControl sample, it is already implemented. Basically the slider gets the image controller from an array of controllers; among other things, when the scroller changes to the previous or next image, controllers are added and removed from this array dynamically to keep memory footprint low.
Have a look at the sample code, it is quite simple.
Hope it helps.
i want to add image into initWithActivityIndicatorStyle instead of using the others like
UIActivityIndicatorViewStyleWhiteLarge. So, when come to loading page, the image will act as
image loading.
Any help, i am truly appreciate it . ^^
Thanks
You can't do that. UIActivityIndicatorView draws the system activity indicators. If you want to display a custom image then you shouldn't be using a UIActivityIndicatorView. Either create a custom view, or if you just want to display an image use a UIImageView. UIImageView also supports animating several images in a loop if you want to do that.