How to make recent images on top of UIImagePickerController? [duplicate] - iphone

This question already has answers here:
UIImagepickercontroller: is it possible to change the sort order of the images in camera roll?
(3 answers)
Closed 9 years ago.
In my iPhone app, user can select photo from device while uploading,
When the click select photo-the UIImagePickerController comes. But its order is recent photos on bottom, so the user have to scroll a lot to select their recent pictures,How can I make it as recent pics on top of UIImagePickerController

With UIImagePickerController it is not possible. However you can overcome this by using ALAssetLibrary and create your controller.
If you are running short in time I will recommend you to use ELCImagePickerController, change the code of ElcAssetTablePicker.m preparePhotos method.
Add following code to it
if(self.tableView.contentSize.height > self.tableView.frame.size.height)
{
CGPoint offset = CGPointMake(0, self.tableView.contentSize.height - self.tableView.frame.size.height);
[self.tableView setContentOffset:offset animated:NO];
}
And bingo you will see it will scroll to bottom of the table. So user can see recent photos directly.
Let me know in case of any query.

You can't do it.
There is no way to adjust the photolibrary data in UIImagePickerController.
If you need this you need to rely on any third party api's or you need to write your on picker which sorts images using their timestamps or asseturl's. (Currently no third party library is available for doing this)

We can do that
just use this in imagepicker
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

Related

UIImagePickerController CameraDevice picks wrong device every other time (using ARC)

My app takes a video (using a custom overlay, in case that's relevant) where I have the cameraDevice set to front facing camera. 3 videos need to be taken, though the cameraDevice alternates between front and rear each time the UIImpagePickerController is called to take the video. On each occasion the
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
is used within the code, though as mentioned the app ignores this command every other time.
I see this problem has been asked before, though I am using ARC so the previously suggested solutions of releasing the UIImagePickerController is not an option for me.
Thanks in advance, Jim.
You cannot release the picker in ARC but you can still create a brand new one like this:
picker = nil;
picker = [[UIImagePickerController alloc] init];
// configure picker
Notice that in Apple's sample code "Using UIImagePickerController to Select Pictures and Take Photos" they call a method each time which does exactly this.

Take picture and set it to UIImageView in iOS [duplicate]

This question already has answers here:
Taking a picture from the camera and show it in a UIImageView
(2 answers)
Closed 9 years ago.
Is there a way to take a picture on the iPad without going through the Apple controls ? I have seen a bunch of apps that do this,
For example, when you add a new contact in iPhone, on the top left side it shows add photo when we click on that, camera opens up and it takes pic and saves to add photo..
I want to implement same functionality.. is it possible on iPad ?
What you need to do is , Add a button first, with the title "Add Photo" or with custom image.
Then on the click of the button add the following code :
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController: cameraUI animated: YES completion:nil];
It will open up the camera, then you click the image and then tap "use" and You have to implement the UIImagePickerControllerDelegate method imagePickerController:didFinishPickingMediaWithInfo: and then store the UIImage to wherever you want, with whatever file name you want, using NSFileManager methods.
Using image picker controller you can use the same functionality as you described in your question.
For that you need to convert the picture into image data & display it in uiimageview
You can refer this : UIImageView Class Reference
This will provide you examples too.
This answer of Taking a picture from the camera and show it in a UIImageView will provide you proper answer..
Enjoy Programming!!

Existing ios project making compatible with iPhone 5 [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?
I already have a project which is running properly on iPhone 4 and iPad. Now I want to make that project compatible with iPhone 5 (4 inches).
I have tried using the "Use Auto Layout" but its not working.
My Xcode version is Version 4.5 (4G182).
I have searched over the internet but couldn't find any clue.
If anyone has already resolved this issue then please guide me.
put a Default Image for iPhone 5 in the project called Default-568h#2x.png.
After that the iPhone 5 simulator launched my App fullscreen.
Depending on your Layout you maybe don't need auto layout. I could solve all layout problems with the autoresizing settings in IB. In the end it was simple. I had four kinds of problems:
View Controllers that should be fullscreen
Elements with fixed distance to the top
Elements with fixed distance to the bottom
Elements with dynamic distance to top/ bottom that should be scaled with the size of the container
I preffered this way in my existing project. In the next project I will check out the auto layout functionality.
Best,
Benjamin
I won't recommend creating a separate xib file, This is what I do:
1. Adding 4-inch launch screen - it's a must if you want to use all iPhone 5 screen, There is no other settings for that.
2. If you are using a xib file just open it with interface builder and select every view button etc. and set it to be dynamically placed (using the ruler tab). Pay attention to set windows also to stretch up.
3. If you code your view check that you are dynamically set the places and sizes.
Pay attention that "Auto Layout" isn't backwards compatible so it won't run on versions of iOS before iOS6 (it simply crash)! It is probably useful if you are starting from scratch but for old apps that isn't so good.
Have you tried adding a new launch image named Default-568h#2x.png to your project?
One of the possible solutions (probably not the best one) is to load different .xib files depending on screen size. This way you can stil save compatibility with previous iOS versions (<6.0).
You can add a category which selects proper .xib file, instead of initWithNibName:
#implementation UIViewController (iPhone5Support)
-(id) initAutomaticallyWithNibName:(NSString *)nibNameOrNil orIOS6NibName:(NSString*) IOS6NibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
BOOL isiPhone5 = CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size,CGSizeMake(640, 1136));
if (isiPhone5==NO) {
self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
} else {
self = [self initWithNibName:IOS6NibNameOrNil bundle:nibBundleOrNil];
if (self==nil) { NSLog(#" initAutomaticallyWithNibName ERROR - nil for io6 nib name"); }
}
return self;
}
#end
Use it like that:
UIViewController *controller = [[UIViewController alloc] initAutomaticallyWithNibName:#"UIViewControllerXibName" orIOS6NibName:#"UIViewControllerXibName_4inch" bundle:nil];
(don't forget to create 2 xib files for the same controller)

Displaying Map ONLY when the button is clicked in Xcode

I am developing an iPhone application using XCode and I am kinda stuck with the functionality described in the subject of this post.
I want the map(using MapKit) to only load and display after I click a button. So, what code should I have under that my "(IBAction) showMap" function?
Whatever I could find online talks about unhiding the map. I want to only load the map when a button is clicked rather than loading the map in the background and simply unhiding it the click of the the button. Thanks !
~Susanth
Your button click should open a new view, which contains Map. Since that view does not exist until it's loaded (viewDidLoad, viewWillAppear), you are not loading map or displaying it beforehands.
- (IBAction)showMap:(id)sender
{
self.mapController = [[MyMapViewController alloc]
initWithNibName:#"MyMapViewController" bundle:nil];
[self.mainView addSubview:mapController.view];
}
Many ways to do it... It takes time to load a map, so you might still consider loading it at background. Looks better (faster) for end-user.
use the below concept.
-(IBAction) showMap:(id)sender
{
// Add your Map to current view
[self.view addsubview:YOUR_MAPVIEW];
}
-(IBAction) hideMap:(id)sender
{
[YOURMAPVIEW removeFromSuperView];
}
Here you can create the MapView either from XIB file or by writing code.
Hope this helps.
Jim.

Is it possible to use pickerview in cocos2d?

Duplicate:
How can i use picker view in iphone application using cocos2d ?
Is it possible to use pickerview in iphone application using cocos2d ? If possible then can i do that in my application.Where i can get this information.If not then what are the other solution for doing this in pickerview.
I haven't looked into cocos2d at all, but I assume that if you still have access to the UIKit fameworks within your app you should be able to create an instance of UIPickerView.
However, I'm not sure you'll be able to used it the way you're intending without some subclassing or writing your own. The picker view is intended to be used by the user to pick an item from a selection, not to be automatically spun by the app...
Yes you can use UIKit controls in Cocos2DIPhone.
You just need to attach them directly to the application window.
There are examples in the docs and on the cocos2d message board. Riq is excellent with questions/feedback on the message board there as well.
I have used the UIImagePicker controller in my application using the steps below:
// 1 - instantiate your picker (in my case UIImagePicker):
pickerController = [[UIImagePickerController alloc] init];
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.delegate = self;
// 2 - add the picker view as a subview of the actual scene
[[Director sharedDirector] openGLView] addSubview:pickerController.view];
It worked for me but the transition is not animated.