Removing UIPopOver permittedArrowDirections - objective-c

I have a UIPopOverController and this is my code:
[myPopOver presentPopoverFromRect:CGRectMake(20,5, 325, 600) inView:self.view permittedArrowDirections:**UIPopoverArrowDirectionLeft** animated:YES];
However I need no direction arrows.can any one tell me how can I do it. How can I remove the arrow from it?
Now myPopOver displaying 4 photolibrary images on a Row.can any one tell me how can arrange or display only two images on a row in myPopOver controller.
And also it dismissing when I click on ay place.I don't want to dismiss it.is the any property to avoid the dismiss of uipopover?
I used the code
imagePopOver = [[UIPopoverController alloc] initWithContentViewController:self.plc.imagePickerController];
imagePopOver.popoverContentSize = CGSizeMake(150,300);

You can remove arrow from UIPopover with the help of below code.
[popOverController presentPopoverFromRect:CGRectMake(200, 300, 335, 332) inView:self.view permittedArrowDirections:NO animated:YES];

in swift
let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .ActionSheet)
alertController.popoverPresentationController?.permittedArrowDirections = []

You cannot have no direction arrows with a UIPopover. If you just want a view that appears than you will need to make your own custom UIView and hide it or turn the alpha to 0 and fade it in when you need it. As far as view layout goes you can set the frame property of your image views that you are showing to control where they are placed.

My solution in SWIFT:
popover!.permittedArrowDirections = nil

Related

how to dissmiss a popover on button click and how to change the size

I am using UIPopover to display videos using UIImagePickerController.In this I have to dismiss my popover when use is clicked.Can anyone please help me to do this?
Also I want to change the size of the popover.Now I am using the below code to chane the size.But it is not working.Width is not getting changed.
[popOver1 setPopoverContentSize:CGSizeMake(1000.0 , 500.0) animated:YES];
Please give me a solution for these two problems..
For dismissing popover controller you can use below code in button action method.
[popoverController dismissPopoverAnimated:YES];
For changing the width you can change the frame of the popover controller not contentSize.
popoverRect = CGRectMake(x, y, width,height);
i found you are trying like this
[popOver1 setPopoverContentSize:CGSizeMake(1000.0 , 500.0) animated:YES];
//it means in increases the contentSize not the width

Can't hide back button inside my navigationbar

I am trying to hide my backbutton in the firstView after I logged into the application. I have this piece of code inside my ViewWillAppear.
self.navigationController.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = NO;
But my back button will not dissapear.
any help ?
Kind regards.
use this instead
self.navigationItem.hidesBackButton = YES;
Try these couple of lines , this will work out:
self.navigationItem.hidesBackButton = TRUE;
self.navigationItem.leftBarButtonItem = nil;
You can set a custom UIBarButtonItem as left bar button. That one you can try to hide or desing in a smooth way that it helps achieving what you want to do.
If you want to hide back button, than maybe you do not want to get back to previous screen. If this is the case, instead of pushing navigation controller show your view modally.
Otherwise do the following:
UIButton* myButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
UIBarButtonItem* myBarButton=[[UIBarButtonItem alloc] initWithCustomView:myButton];
myButton.hidden = YES;

iPad: Popover windows got resized iOS

CGRect rect = CGRectMake(0, 0, 1050, 900);
[wineAdminPopup presentPopoverFromRect:rect inView:master.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Hi I put the above code to make a popup in a tableview. However it doesn't popup in the whole screen. If I want to center it in the iPad screen with no arrow or arrow in the center. How can i do it. Thanks in advance.
The rect parameter in presentPopoverFromRect:... specifies the rectangle at which to anchor the popover, not the size of the presented popover. That would be specified by setting contentSizeForViewInPopover on the popover's content view controller.
If you don't want the arrows and don't need the specific behavior of popovers, then you could
present your view controller modally:
controller.modalPresentationStyle = UIModalPresentationFullScreen; // or UIModalPresentationFormSheet
[self.navigationController presentModalViewController:controller animated:YES];
presentModalViewController is deprecated in iOS 6 and above. Use presentViewController:yourViewController animated:YES completion:nil (parameters animated and completion can be set depending on your requirements). Also if you want to resize yourViewController you need to change self.view.frame and next time your view controller will be of that size.

UIPopover Not Showing View Inside

I'm using a popover that should simply show a UIView inside. But although the popup shows up, it contains only an empty view (that is colored in some kind of dark blue).
The UIViewController is use is the "PreferencesController" in there.
My Code to open the popup is the following:
- (IBAction)showPopup:(id)sender {
if (_preferencesController == nil) {
self.preferencesController = [[PreferencesController alloc]init];
self.preferencesControllerPopover = [[UIPopoverController alloc]
initWithContentViewController:_preferencesController];
}
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:0 animated:YES];
}
Besides that I only have the "preferencesController" that doesn't include any special methods besides the viewDidLoad with "self.contentSizeForViewInPopover = CGSizeMake(800.0, 800.0);"
This is what I get:
Any ideas why it isn't working properly?
Possible Problem
800.0 width is too large for a Popover to handle.
In the documentation for UIViewController:
(Discussing contentSizeForViewInPopover)
This property contains the desired size for the view controller when it is displayed in a popover. By default, the width is set to 320 points and the height is set to 1100 points. You can change these values as needed.
The recommended width for popovers is 320 points. If needed, you can return a width value as large as 600 points, but doing so is not recommended.
Possible Solution
Try presenting your UIViewController modally by calling presentModalViewController:animated: from the UIViewController you want the modal view controller to animate on top of.
I think this code makes the issue:
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:0 animated:YES];
Because sender is of type id, so you need to cast it, Like:
UIBarButtonItem *but = (UIBarButtonItem *)sender;
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:but permittedArrowDirections:0 animated:YES];
Hope it'll solve the issue.

UITableView in Popover scrolls out of bounds when keyboard is opened

I have a popover that contains a UITableView. This UITableView has a cell with a text field in it:
alt text http://cl.ly/1b50a21ca8202d22db1b/content
When the popover opens near the bottom of the screen, and I tap the text field to edit it, the keyboard comes up, and the popover moves up to avoid being covered by the keyboard. But as it moves up, the table view in the popover scrolls up out of bounds:
alt text http://cl.ly/4fe64fbfe9518f20560d/content
I can scroll it back down, but how do I prevent this from happening.
I've come to the conclusion that this is a bug. I have filed a bug report with Apple (rdar://8156616) as well as a report on OpenRadar.
For anyone interested, here is a sample project that demonstrates the issue.
Try disabling scrolling on the table view.
[self.tableView scrollingEnabled:NO];
How are you setting the content view of your pop over controller. Please try editing the auto-resizing mask of the content view and set it from top-left.
Hope this helps.
Thanks,
Madhup
Perhaps you can set the UITableView's contentSize manually? So that there is no excess for it to scroll up.
I had the same problem but when hiding the keyboard and reloading the table view!
There is one solution for this problem! What you have to do is first hide the keyboard and reload the table view or change the table view in method recieving keyboard did hide notification!
At first I called
[textView resignFirstResponder]; or [textField resignFirstResponder];
and then
-(void)keyboardDidHide:(NSNotification *)notif {
//Check some conditions if you want
[tableView reloadData];
}
You need to listen to the keyboard will show notification:
NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardStatusForPopover(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
Then you have to see if the keyboard frame intersects with the popover and subtract the values added from the keyboard to the popover container frame:
#objc func handleKeyboardStatusForPopover(_ notification: Notification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
if keyboardSize.intersects((self.resultPopOverTableViewController!.view.superview!.superview!.frame).insetBy(dx: 0, dy: 60)) {
let popOverContainer = viewControllerDisplayedbyPopover?.view.superview!.superview!
// cellDisplayingDetailInfo = sourceview of popover
popOverContainer!.frame.origin.y = popOverContainer!.frame.minY - keyboardSize.height + cellDisplayingDetailInfo.frame.maxY
}
}
}