I am using ABPeoplePickerNavigationController for selection of address book contact by user. With this code behind action of a button:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.view.frame=self.view.frame;
[self presentModalViewController:picker animated:YES];
[picker release];
When this code runs it rotates the Landscape UI to Portrait and eventually dismisses the controller that presents this ABPeoplePickerNavigationController.
I am getting this problem only in iOS 5, iPad 2. It's working fine with iOS 6.
I don't believe in 5.x that landscape is supported for this picker. However, try doing it via a different PresentationStyle. I believe it should then work in landscape, i.e:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:picker animated:YES];
Related
I'm implementing a CABTMIDICentralViewController (Apple's pre-fab BTLE MIDI configuration panel). The code below is Apple's sample code - unmodified.
It works perfectly on iPad, but on iPhone/iPod it results in an uncloseable fullscreen view. The code clearly creates a Done button, but it isn't shown on the devices.
The common answer is "you need a UINavigationController", but there is one being made in this code. So I'm not sure what else is missing?
- (void)doneAction:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)configureCentral:(id)sender
{
CABTMIDICentralViewController *viewController [CABTMIDICentralViewController new];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
// this will present a view controller as a popover in iPad and modal VC on iPhone
viewController.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:#selector(doneAction:)];
navController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popC = navController.popoverPresentationController;
popC.permittedArrowDirections = UIPopoverArrowDirectionAny;
popC.sourceRect = [sender frame];
UIButton *button = (UIButton *)sender;
popC.sourceView = button.superview;
[self presentViewController:navController animated:YES completion:nil];
}
You will have to implement the UIPopoverPresentationControllerDelegate to view popovers in iPhones. By default it will be presented in the style of an already presented view controller.
Add this piece of code to present the controller as popover
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(nonnull UITraitCollection *)traitCollection {
return UIModalPresentationNone;
}
In IOS6 I am using following method to get photo from I Pad photo Library.But now its not working for IOS7
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerCameraCaptureModePhoto;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[picker release], picker = nil;
What is issue with IOS7
Here you can use custom Frame and load the popover ;)
[popOver presentPopoverFromRect:CGRectMake(self.view.frame.size.width-50, 50, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Check out UIImagePickerController crash only on iOS 7 - iPad
Its Probably an iOS 7 Bug. Probably your personal hotspot is on at the moment try to turn it off at and run the application
When I invoke camera using the UIimagepicker controller it does not show in full screen mode on iPhone with iOS version 4.2, but it does work in iOS 5.
Can anyone tell me the code that needs to be changed and what is the problem with existing code?
I am using the following code:
- (IBAction)takePicture:(id)sender
{
UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = YES;
imagePicker.allowsEditing = NO;
imagePicker.toolbarHidden = YES;
imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
imagePicker.wantsFullScreenLayout = YES;
if ([UIImagePickerController respondsToSelector:#selector(isCameraDeviceAvailable:)])
{
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront])
{
[imagePicker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
}
}
// Show the camera UI and View Finder.
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
Please check the attachment
Image is here
one of the solution is applying scaling trasnformation - here on stack maybe it will help
I don't see why you are doing these 3 things:
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[self.camPicker.view setUserInteractionEnabled:YES];
Or for that matter why you are caching the instance of UIImagePickerController (this may cause significantly higher idle memory usage for your application compared to discarding the image picker controller between uses).
Does it work better if you don't do these things?
I have a Master/Detail application and have a button on the top right of the MasterViewController in the split view that loads an "Info" view controller using a modal view:
When the button is clicked, the view is loaded, and populates the entire screen in iOS 5.0 and below (this is the behavior that I want):
- (IBAction)showAppInfo:(id)sender
{
InfoViewController *infoViewController = [[InfoViewController alloc]
initWithNibName:#"InfoViewController" bundle:nil];
infoViewController.delegate = self;
[self presentModalViewController: infoViewController animated: YES];
}
However, when I run this in the iOS 5.1 simulator, it no longer populates the entire iPad screen, and only populates what's inside the Master View:
What can I do to make this InfoViewController populate the entire screen in iOS 5.1 as it did before?
I assume you are using UIPopoverController, try this
InfoViewController *infoViewController = [[InfoViewController alloc]
initWithNibName:#"InfoViewController" bundle:nil];
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:infoViewController];
popoverController.popoverContentSize = CGSizeMake(500.0, 583.0);
popoverController.delegate = self;
[popoverController presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I am making an app for the iPad and want to be able to use the iPad 2 camera if available. Is the code to load the iPad camera the same as for the iPhone 4? I have this same code working on the iPhone version of this app, but do not have an iPad 2 to test with and simulator can't help me with the camera. Below is what I have to determine if camera is available and then to load camera or load library in popup
Basically I just need to know if the line below is supported by the iPad 2 camera or do I need to use something else?
[self presentModalViewController:imagePickerController animated:YES];
I want camera to be full screen and not in a popup.
- (IBAction) takePhoto:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self presentModalViewController:imagePickerController animated:YES];
} else {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
imageView.contentMode = UIViewContentModeScaleAspectFit;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popover setDelegate:self];
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
Yes this works, for sure if self is a UINavigationController. I know this because I do the same in my app. I'm not sure for other UIViewControllers, but it stands to reason that it will also work.