UIPopoverController is not presenting on "presentViewController" - ios

I am developing iPad application. In this application i am showing ViewController in presentViewController using this following code
[self presentViewController:vc animated:YES completion:nil];
After that i am showing popup using UIPopoverController in that presentviewController with out dismissing "vc". so that i am getting the issue following issue Warning: Attempt to present <SelectionListViewController: 0x7b439960> on <ViewController: 0x7a341e00> which is already presenting (null)
So that the popup is not presenting on ViewController. how to solve this issue. This is existing project now i need to fix this issue.
Thanks in Advance

Present in this manner...
vc.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popController = [vc popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.sourceView = self.view;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self presentViewController:vc animated:YES completion:nil];
}];

I think presentViewController in a performSelector call will solve your problem.
Try this 2 Methods
-(void) present
{
[self performSelector: #selector(ShowSelectionListViewController) withObject: nil afterDelay: 0];
}
-(void) ShowSelectionListViewController
{
[self presentViewController:SelectionListViewController animated: true completion: nil];
}

You should try this one. it worked for me...
if([AppDelegate isIOS8])
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(),
^{[self.popover presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];});
}
else
{
[self.popover presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES ];
}

Related

ViewController dismissViewControllerAnimated immediately after presentViewController

I tried to hide a ViewController using "dismissViewControllerAnimated" immediately after "presentViewController"
AddTaskViewController *add = [[AddTaskViewController alloc] init];
[self presentViewController:add animated:NO completion:nil];
[add dismissViewControllerAnimated:YES completion:nil];
but I have a delay before the ViewController is hidded ?
Thanks

'Warning:Attempt to present ^ on UINavigationController: 0x7d090c00 while a presentation is in progress!'on using the UIPopoverPresentationController

I'm getting warning like this 'Warning:Attempt to present KKContactTypeTableViewController: 0x7b6f2170 on UINavigationController: 0x7d090c00 while a presentation is in progress!'on using the UIPopoverPresentationController.Like this at viewController A for pushing a UIPopoverPresentationController:
-(void)contactTypePopView{
_contactTypePopController = [[KKContactTypeTableViewController alloc] init];
_contactTypePopController.modalPresentationStyle = UIModalPresentationPopover;
//[self presentViewController:_contactTypePopController animated:YES completion:nil];
[self.view.window.rootViewController presentViewController:_contactTypePopController animated:YES completion:nil];
UIPopoverPresentationController *popPresent = [_contactTypePopController popoverPresentationController];
popPresent.delegate = self;
popPresent.permittedArrowDirections = UIPopoverArrowDirectionLeft;
popPresent.sourceView = self.contaxt_type;
popPresent.sourceRect = self.contaxt_type.bounds;
}
and dismiss viewController at KKContactTypeTableViewController like this:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
KKContactTpye *contactType = self.contactTypes[indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:#"ContactType" object:nil userInfo:#{#"ContactTypeName":contactType.Name,#"ContactTypeId":contactType.ID}];
[self dismissViewControllerAnimated:YES completion:nil];
}
and then I push viewController A to B the warning appeared while UIPopoverPresentationController at viewController A is also brought!I searched on Internet and read questions about this but not got any answer.please give a better soluton thanks in advance!

GKGameCenterViewController wont dismiss?

I dont get it please help i DONT get a log when i hit done
- (IBAction)loadScores:(id)sender {
GKGameCenterViewController* gameCenterController = [[GKGameCenterViewController alloc] init];
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
// gameCenterController.gameCenterDelegate = self;
[self presentViewController:gameCenterController animated:YES completion:nil];
}
-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController*)gameCenterViewController {
NSLog(#"rfffff");
[self dismissViewControllerAnimated:YES completion:nil];
UIViewController *vc = self.view.window.rootViewController;
[vc dismissViewControllerAnimated:YES completion:nil];
}
You have commented the delegates of the GKGameCenterViewController. This means all the delegate methods will not be called like the one that dismisses the view controller. So I suggest you uncomment this line and then run the code and see.

In Modal View, DismissViewControllerAnimated After PresentViewController Not Working

I come across this issue while doing some testing. I have presented a Modal view, called ModalView1. In ModalView1, when a button is pressed, another Modal view, called ModalView2 would be presented using presentViewController. Then I tried dismissing ModalView2 using dismissViewControllerAnimated but it is not working.
Here is the code fragment in button action
- (void) buttonAction: (UIButton*) sender
{
ModalView *ModalView2 = [[ModalView alloc] init];
[self presentViewController:ModalView2 animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
}
Any help would be much appreciated. Thank you.
It's not clear what you are trying to do. I give you two options:
Presenting ModalView2 and then dismissing ModalView2 (makes no sense to me, but that's what I can read in your question)
- (void) buttonAction: (UIButton*) sender {
ModalView* modalView2 = [[ModalView alloc] init];
[self presentViewController:modalView2 animated:YES completion:^{
[modalView2 dismissViewControllerAnimated:YES completion:nil];
}];
}
Presenting ModalView2 and dismissing ModalView1:
- (void) buttonAction: (UIButton*) sender {
ModalView* modalView2 = [[ModalView alloc] init];
UIViewController* presentingViewController = self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^{
[presentingViewController presentViewController:modalView2 animated:YES completion:nil];
}];
}
at time present and dismiss not call so give some time
try this it working me
- (void) buttonAction: (UIButton*) sender
{
[self performSelector:#selector(call) withObject:nil afterDelay:.4];
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)call
{
ModalView *ModalView2 = [[ModalView alloc] init];
[self presentViewController:ModalView2 animated:YES completion:nil];
}

How to delay between 2 animations?

I am dismissing one modal view controller and then immediately presenting another modal view controller however I cannot currently use animation on both of them only the second one.
Is there anyway to delay the process so that the user experiences both animations?
The code below currently works however user only sees the second animation obviously:
// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:detailViewController animated:YES];
//Dismiss first one
[self dismissModalViewControllerAnimated:NO];
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
There is now a completetion block available in present modal view controller. See this LINK. This is available in iOS5.0 +.
This has the advantage that you don't need to estimate the timer delay if you were to use a timer solution.
Just put the code for your second animation in the block:
//Block safe reference to self to prevent retain cycles
__block typeof (self) selfReference = self;
// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:detailViewController animated:YES completion:
^{
//Dismiss first one
[selfReference dismissModalViewControllerAnimated:NO];
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[selfReference presentModalViewController:navController animated:YES];
}];
Make a selector that does the following:
- (void)showSecondModalVC {
//Dismiss first one
[self dismissModalViewControllerAnimated:NO];
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
}
An then in the main piece of code:
// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:detailViewController animated:YES];
[self performSelector:#selector(showSecondModalVC)
withObject:nil
afterDelay:0.5f];
You will have to look closely and see how much it takes for the first modal to show so the animations look good.
You can do it in some other style.
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:detailViewController animated:YES];
[self dismissModalViewControllerAnimated:NO];
[self performSelector:#selector(someFunction) withObject:nil afterDelay:1.0];
- (void) someFunction{
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
}
Try with this:
// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:detailViewController animated:YES];
//Dismiss first one
[self dismissModalViewControllerAnimated:NO];
NSTimer Timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:#selector(openSecondView) userInfo:nil repeats:NO];
-(void)openSecondView
{
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
}
Happy Coding...

Resources