UIButton not showing up on iOS 5.1 iPad - ios

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];
}

Related

UIPopoverController broken in ipad in xcode version 14

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];

Different navigation bar behaviour between CABTMIDILocalPeripheralViewController and CABTMIDICentralViewController

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.

How to show fullscreen popovercontroller in iPhone screen?

I have UIbarbuttonItem in navationbar and than click the button works well iPad simulator but don't work iPhone simulator because Popover not supported iPhone. I trying to show fullscreen popovercontroller in iPhone screen.How to fix this problem. I add my codes and screenshots.
Thanks in advance.
MyCodes;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:#selector(doneButtonPressed:)];
UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:nil];
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *actionButtonItems = #[shareItem, cameraItem, flexibleItem,searchItem];
self.navigationItem.rightBarButtonItems = actionButtonItems;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)doneButtonPressed:(id)sender
{
if(![popoverController isPopoverVisible]){
UIViewController *viewControllerForPopover = [self.storyboard instantiateViewControllerWithIdentifier:#"MyIdentifier"];
popoverController = [[UIPopoverController alloc] initWithContentViewController:viewControllerForPopover];
popoverController.delegate=self;
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//popoverController.passthroughViews=[NSArray arrayWithObjects:self.view, nil];
}
else{
[popoverController dismissPopoverAnimated:YES];
}
}
#interface ViewController : UIViewController<UIPopoverControllerDelegate,UIPopoverPresentationControllerDelegate>{
UIPopoverController *popoverController;
CameraViewController *cameraPopOver;
}
My Screens;
PopoverController can't be added to iPhone as this controller is only for iPad and not for iOS. to solve your issue you can take a simple view or a tableview over there, which will appear on click event of bar button
I once used KGModal.
KGModal is an easy drop in control that allows you to display any view in a modal popup. Can popup UIView and UIViewController.

iPad UIPopover presented over UIBarButtomItem covers BarButtomItem?

I have UIBarButtomItem that shows popover when pressed:
//add help button
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(#"Help", #"Help") style:UIBarButtonItemStylePlain target:self action:#selector(showInfoBubble:)] autorelease];
infoBubblePopOverVisible = NO;
self.infoBubblePopOverController = nil;
Here is show info bubble:
- (void) showInfoBubble: (id) sender {
[self dismissPopoverControllerExplicitly];
if (self.infoBubblePopOverController == nil) {
InfoBubbleViewController *controller = [[InfoBubbleViewController alloc] initWithNibName:#"InfoBubbleViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
self.infoBubblePopOverController = [[UIPopoverController alloc] initWithContentViewController:navigationController];
[controller release];
[navigationController release];
}
//present popOverController
[self.infoBubblePopOverController presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
infoBubblePopOverVisible = YES;
}
But when presented popover is presented partially covering barbuttomitem:
How can i fix this?

how can I display a ABPersonViewController with Edit button in a UIPopOverController

I am trying to enabling the editing of a Contact in a universal app, with a ABPersonViewController displayed in a UIPopoverController. The person does get displayed, but there is no Edit button. In actual fact, I would prefer it if the user saw the details already in an Editable form, but it would be ok if they could do the edit after hitting the Edit button. On the iPhone, it works fine. Can anyone help, please.
ABPersonViewController *view = [[ABPersonViewController alloc] init];
view.personViewDelegate = self;
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef contact = ABAddressBookGetPersonWithRecordID(addressBook,(ABRecordID)recId);
view.displayedPerson = contact;
view.displayedProperties = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonFirstNameProperty], [NSNumber numberWithInt:kABPersonLastNameProperty], [NSNumber numberWithInt:kABPersonAddressProperty], nil];
view.allowsEditing = YES;
view.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(#"Back",nil) style:UIBarButtonItemStylePlain target:self action:#selector(ReturnFromPersonView)] ;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
UIPopoverController *addressPopup;
addressPopup = [[UIPopoverController alloc] initWithContentViewController:view];
addressPopup.delegate = self;
self.popoverController = addressPopup;
[addressPopup release];
[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
else
{
[self.navigationController pushViewController:view animated:YES];
}
if (addressBook) CFRelease(addressBook);
[view release];
You need to add your ABPersonViewController *view explicitly to a UINavigationController.
ABPersonViewController *view = [[ABPersonViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:view];
UIPopoverController *personViewPopover = [[UIPopoverController alloc] initWithContentViewController:navController];

Resources