In my app the popup is shown in the center of the screen. In ipad 10th generation it fails and shows in the left side of the screen.
Code:
popover = [[UIPopoverController alloc] initWithContentViewController:tsv];
popover.delegate = self;
if ([popover respondsToSelector:#selector(setBackgroundColor:)])
popover.backgroundColor = [UIColor whiteColor];
[topics release];
}
self.titleHeaderImage.highlighted = YES;
[popover presentPopoverFromRect:self.titleView.frame inView:self.navigationController.view permittedArrowDirections:UIPopoverArrowDirectionL animated:YES];
Related
I am struggling to understand why the following views, one for CABTMIDILocalPeripheralViewController and the other for CABTMIDICentralViewController show different behaviour in my iOS app (written in Objective-C)
- (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];
viewController.preferredContentSize = CGSizeMake(320., 400.);
popC.backgroundColor = [UIColor darkGrayColor];
viewController.view.backgroundColor = [UIColor darkGrayColor];
UIButton *button = (UIButton *)sender;
popC.sourceView = button.superview;
[self presentViewController:navController animated:NO completion:nil];
}
Opens a popup view on an iOS device, which does not show any 'done' button to dismiss the view.
CABTMIDICentralViewController shows no button to close/dismiss the view
While on an iPad tapping outside the view will close it, on an iPhone the view takes the size of the screen and exiting/closing becomes impossible.
The same code used for the CABTMIDILocalPeripheralViewController works as expected.
- (IBAction)configureLocalPeripheral:(id)sender
{
CABTMIDILocalPeripheralViewController *vController = [[CABTMIDILocalPeripheralViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vController];
vController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:#selector(doneWithPeripheral:)];
navController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popC = navController.popoverPresentationController;
popC.permittedArrowDirections = UIPopoverArrowDirectionAny;
popC.sourceRect = [sender frame];
vController.preferredContentSize = CGSizeMake(320., 400.);
popC.backgroundColor = [UIColor grayColor];
vController.view.backgroundColor = [UIColor darkGrayColor];
UIButton *button = (UIButton *)sender;
popC.sourceView = button.superview;
[self presentViewController:navController animated:NO completion:nil];
}
CABTMIDILocalPeripheralViewController has a 'done' button
What is going wrong here? I have tested to make the views wider to see whether available space in the Navigation bar would have caused this.
Thanks.
I am trying to display a MPMediaPickerController in a popover on iOS7+ and it is VERY slow. It takes about 4 seconds from the first NSLog to the second NSLog. I have tried retaining the picker but this makes no difference. Any ideas would be greatly appreciated.
- (void) showMediaPickerControllerWithArrowDirection:(UIPopoverArrowDirection)arrow_direction
{
MPMediaPickerController *self.picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio];
self.picker.modalPresentationStyle = UIModalPresentationPopover;
self.picker.delegate = self;
self.picker.allowsPickingMultipleItems = YES;
UIPopoverPresentationController *popPresenter = self.picker.popoverPresentationController;
popPresenter.sourceView = self.view;
popPresenter.sourceRect = self.view.bounds;
popPresenter.permittedArrowDirections = arrow_direction;
NSLog(#"____________________________ about to launch picker ");
[self.viewController presentViewController:self.picker animated:YES completion:^{
NSLog(#"____________________________ picker launched ");
}];
}
I need to set the position for my Modal popup. Its working fine lesser than IOS 7 only problem with IOS 7. I could not able to set coordinate of the Modal Popup. Its not taking the any values.
MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationPageSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(40, 80, 944, 650);
I have an iPad app in which when I click on the button it opens a popover with the iPad library to see the photos and pics. I want that when I click the button it should also show video in that but it does not show videos.
In device when I see library it shows videos but when popover opens in app it does not show any video.
UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
pckrImage.delegate = self;
if (isiPhone) {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:pckrImage animated:YES];
}
}
else {
popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
[popOver presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
First Create normal popover then add this code to for button 'choose photo from gallery'
UIImagePickerController *imagePicker1 = [[UIImagePickerController alloc] init];
imagePicker1.contentSizeForViewInPopover=CGSizeMake(300, 200);
imagePicker1.delegate = self;
imagePicker1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Popcontroller = [[UIPopoverController alloc] initWithContentViewController:imagePicker1];
[Popcontroller presentPopoverFromRect:cell1.ButtonAddPicture.frame
inView:cell1.ButtonAddPicture.superview
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
and for video add following line to above code
imagePicker1.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
UIBarButtonItem not showing up on iOS 5.1 iPad 1, but works with iOS 6 on iPad 4.
_itemForImport = [[UIBarButtonItem alloc] initWithTitle:LS(#"Library", #"") style:UIBarButtonItemStyleBordered target:self action:#selector(itemForImportTouched)];
+ (void) presentInPopoverFromBarButtonItem:(UIBarButtonItem *)item withSourceType:(NSString*)sourceType {
UIPopoverController* popover = [IPadFilesViewController getPopoverController];
if (popover)
return;
IPadImagePickerController* pickerController = [[IPadImagePickerController alloc] initWithSourceType:sourceType];
popover = [[UIPopoverController alloc] initWithContentViewController:pickerController];
popover.delegate = pickerController;
[IPadFilesViewController setPopoverController:popover];
[popover presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}