Would like to learn how UIPopoverController style UIViews are created.Below is the image from Storehouse iOS app running on iPhone(apple design award winner) , you can see the view moreover looks like UIPopoverController ,any help is greatly appreciated.
You can handle your own custom view check out this How to Place custom view in IOS over another view
You can use this
- (IBAction)ContinueToPayment:(id)sender {
PayByVC *Newpage = [[PayByVC alloc] initWithNibName:#"PayByVC" bundle:nil];
Newpage.checkOutInfoDict=checkOutDict;
Newpage.modalPresentationStyle = UIModalPresentationOverCurrentContext;
Newpage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
Newpage.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.4];
Newpage.delegate = self;
[self presentViewController:Newpage animated:YES completion:nil];
}
Related
On iPad UIPopoverPresentationController working fine but on iPhone it is always showing full window modal popup. i am using following code:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MySecondViewController *contentVC = [storyboard instantiateViewControllerWithIdentifier:#"Pop"];
contentVC.modalPresentationStyle = UINavigationControllerOperationPop; // 13
UIPopoverPresentationController *popPC = contentVC.popoverPresentationController; // 14
contentVC.popoverPresentationController.sourceRect =CGRectMake(100, 130, 280, 230);
self.navigationController.preferredContentSize = CGSizeMake(200, self.parentViewController.childViewControllers.lastObject.preferredContentSize.height-100);
//self.showPop.frame; // 15
contentVC.popoverPresentationController.sourceView =
self.showPop; // 16
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny; // 17
popPC.delegate = self; //18
[self presentViewController:contentVC animated:YES completion:nil];
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
In ViewController.h Firstly make a property of UIPopoverPresenatationController.
#property(nonatomic,retain)UIPopoverPresentationController *dateTimePopover8;
Then to show PopOverPresentationcontroller
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:dateVC];/*Here dateVC is controller you want to show in popover*/
dateVC.preferredContentSize = CGSizeMake(280,200);
destNav.modalPresentationStyle = UIModalPresentationPopover;
_dateTimePopover8 = destNav.popoverPresentationController;
_dateTimePopover8.delegate = self;
_dateTimePopover8.sourceView = self.view;
_dateTimePopover8.sourceRect = [sender frame];
destNav.modalPresentationStyle = UIModalPresentationPopover;
destNav.navigationBarHidden = YES;
[self presentViewController:destNav animated:YES completion:nil];
You must have noticed that we are presenting View Controller instead of presenting popOver.So we have to hide this in new way also.It hides automatically when we click on screen.
-(void)hideIOS8PopOver
{
[self dismissViewControllerAnimated:YES completion:nil];
}
We have to implement the delegate of UIPopoverPresenatationController in implementation file.Write below delegate method in implementation file.
- (UIModalPresentationStyle) adaptivePresentationStyleForPresentationController: (UIPresentationController * ) controller {
return UIModalPresentationNone;
}
Popover controllers are for use exclusively on iPad devices.
Edit: As stated by Soberman, since iOS 8 it is possible to present popovers on iPhone using public APIs, so this answer is probably not relevant anymore.
As stated in Apple's documentation on UIPopoverController:
Popover controllers are for use exclusively on iPad devices.
So there is no way to use this class in iPhone application unfortunately. But there are a couple of custom third-party implementations of the functionality provided by UIPopoverController which add iPhone support and more. See https://github.com/50pixels/FPPopover for example.
Edit: There also is another highly customizable popover implementation for both iPhone/iPad worth checking out: https://github.com/nicolaschengdev/WYPopoverController.
In my app, I do a search asynchronously. When that completes my mapViewController with pins for the locations is displayed. 2 seconds after that, I do a modal transition over to a listViewController. I set the backgroundcolor like this:
self.view.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.65];
Making it possible to see the map behind it.
The problem is this: Less then a second after the listView appears you can see the map in the background for a second before it goes away. What I can see in the background now, is the mainViewController the app starts with.
it looks like this:
Less than a second later:
Any help/explanation would be greatly appreciated.
Your view is still transparent, but once your modal controller is at the top of the stack, the view behind it is hidden.
Try using :
yourController.modalPresentationStyle = UIModalPresentationCurrentContext;
[yourController present...];
This code seems to work. I hope it will help.
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
MKMapView *mapView = [MKMapView new];
[self.view addSubview:mapView];
mapView.frame = self.view.bounds;
UIGestureRecognizer *gestureRecognizer = [UITapGestureRecognizer new];
[gestureRecognizer addTarget:self action:#selector(displayTransparentVC)];
[self.view addGestureRecognizer:gestureRecognizer];
}
-(void)displayTransparentVC
{
UIViewController *vc = [TransparentViewController new];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:YES completion:^{
}];
}
In my iOS app i present standerd controllers MFMessageComposeViewController and UIImagePickerController.
But they both presenting with strange navigation bar.
How can i fix this problem?
UPD code for presenting controllers
UIImagePickerController:
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = sourceType;
cameraUI.allowsEditing = YES;
cameraUI.delegate = self;
[self presentViewController:cameraUI animated:YES completion:nil];
MFMessageComposeViewController:
MFMessageComposeViewController *messageViewController = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]) {
messageViewController.view.backgroundColor = [UIColor whiteColor];
messageViewController.messageComposeDelegate = self;
recipient= [NSStringMask maskString:recipient withPattern:#"\\+(\\d{1}) \\((\\d{3})\\) (\\d{3})-(\\d{2})-(\\d{2})"];
messageViewController.recipients = #[recipient];
messageViewController.body = body;
[self presentViewController:messageViewController animated:YES completion:nil];
}
In iOS 7, the status bar and the navigation is translucent by default. To make the view act 'normal' like in iOS 6. you need to add this to the controller you are presenting.
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
If you want to read up more about changes in views. Check out this post. I find it a nice quick overview whats changed.
http://www.brianjcoleman.com/ios7-weve-got-a-problem/
See this question. I used the second answer, though I suspect the first would work for me also.
How to I change the size of modal dialog? Why is this not working?
SlingDialogViewController *slingDialog = [[SlingDialogViewController alloc] init];
slingDialog.modalPresentationStyle = UIModalPresentationFormSheet;
slingDialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
slingDialog.view.superview.frame = CGRectMake(0, 0, 900, 700);
[self presentModalViewController:slingDialog animated:YES];
Do this:
SlingDialogViewController *slingDialog = [[SlingDialogViewController alloc] init];
slingDialog.modalPresentationStyle = UIModalPresentationFormSheet;
slingDialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:navController animated:YES completion:nil];
slingDialog.view.superview.frame = CGRectMake(0, 0, 900, 700);
slingDialog.view.superview.center = self.view.center;
It's important to call presentViewController:animated:completion first, from my experience at least.
The modal controllers in iOS have fixed sizes. I don't recommend trying to change them, it never works reliably.
A workaround is to implement it by yourself. A modal (presented) controller is a very simple functionality:
A view overlapping your presenting controller, so that it can't be clicked (and it is dimming the contents to make them look backgroundish)
A child view controller (and its view) added to your controller.
So I have a popover with a button in it. When that button is pushed, I want the popover to go away. It seems easy enough, but I can't figure it out for the life of me. The code I use to show the popover is below:
AddCategoryViewController* content = [[AddCategoryViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.addCategoryPopover = aPopover;
[aPopover release];
[addCategoryPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Within the addcategoryviewcontroller, I have:
-(IBAction)saveAddCategory:(id)sender {
if (rootViewController == nil)
rootViewController = [[RootViewController alloc] init];
[rootViewController.addCategoryPopover dismissPopoverAnimated:YES];
[rootViewController dismissPopover];
}
Rootviewcontroller is where the popover is being created from. Unfortunately, neither of those methods work to dismiss it. any help?
You would be seeing a warning at this line.
aPopover.delegate = self;
and if you would execute your code. The app would crash. Instead you need to do it like this.
I have
- (void)viewWillDisappear:(BOOL)anAnimated
{
[self.dPopover dismissPopoverAnimated: NO];
self.dPopover = nil;
[super viewWillDisappear: anAnimated];
}
and don't see why this wouldn't work in your case.
Your if is a bit troubling, so my guess is you aren't talking to the view you think you are. rootViewController.addCategoryPopover is probably nil, because you made a new controller.
I think I answered just a similar question with the solution I used to dismiss a popover with a UIView loaded from a MKMapView.
The use of my solution is basically the same as for any other view loading a popover.
Have a look at:
How to dismissPopoverAnimated on iPad with UIPopoverController in MKMapView (SDK3.2). I hope that solved your problem.
use NSNotificationCenter To DissmissPoperController Fro Father viewControll