I have a modal in my Ionic 2 app. In this modal, clicking on a button, a confirmation prompt ("Are you sure?") pops up. By clicking yes, I do certain operations, then dismiss the modal by calling this method:
close() {
this._viewCtrl.dismiss();
}
and _viewCtrl is the property of my class, which i defined this way in the constructor:
constructor(
public _nav: NavController,
public _viewCtrl: ViewController,
public _profile: Profile,
params: NavParams) { ... }
My problem is that behind the modal I have a "3 Tabs Page", sort of. All works well, the 3 tabs are just fine, my modal is ok, it dismisses as it should, the problem is that when the modal is dismissed the 3 tabs break! They freeze on the second tab (which is the one that calls the modal)! Even if I click on tab 1 and 3, I see only the content for tab 2, and I can do nothing.
I'm pretty sure the operations before the dismiss shouldn't be a problem. I found that if I comment out the this.close(); part, and everything goes fine! The modal doesn't close, but I can close it by hand (with the same function, that's the strange thing!) then I return to the tabs page and the tabs are just fine.
What is happening to the app?
PS. No error is shown in the console!
If you check in the console you will see the modal overlay is still there. That's why when you click on any button on your app, you got no reaction cos you click on the transparent overlay.
I had similar issue now, where I had the dismissal of a Modal working before with Ionic 2 Beta 6, but on the latest Beta 10 it isn't working anymore.
How my logic worked was:
Do server call (while displaying progress with the Loading component
When call returns from server, then dismissing the Loading and then the Modal, but calling them in a synchronous fashion
Now this doesn't work with latest Beta. What I had to do was:
this.loading.onDismiss(() => {
this.viewController.dismiss();
});
this.loading.dismiss();
I got this workaround from here:
https://github.com/driftyco/ionic/issues/6325
Related
This seems like a simple thing but I wasn't able to implement it and didn't find information on it.
I have an ionic Loading Controller that initiates when processing some data. This might take time so the user might decide to cancel. So I would like to simply add a cancel button in the loading element which dismisses the loading controller and returns to the previous page.
this.loading = this.loadingCtrl.create({
content: 'Loading ... (cancel button here?)'
});
this.loading.present();
As far s I know it is not supported. I did it with a modal, it works nearly the same and has the same syntax, but you don't have the transparent background.
See: https://www.techiediaries.com/ionic-modals/ for implementation.
I have an NSStatusItem that is properly displaying in the MenuBar. One of the items (when clicked) displays a modal NSWindow from my application, which is meant to perform a one-off task, then disappear. (Eg. the user enters a small bit of text, clicks "Save", and the modal NSWindow goes away.)
The issue occurs when the application is running in the background. The modal window properly appears above whatever application is running in the foreground, but when the user clicks the "Save" button, the rest of the application's windows also are made active. This is undesirable, as the user then has to click back to whatever app they were using. (Destroying the convenience of the NSStatusItem.) I'm displaying the modal window using:
[myWindow setFrame:finalRect display:YES animate:NO];
[myWindow setLevel:NSPopUpMenuWindowLevel];
[NSApp runModalForWindow:myWindow];
Is there any way to prevent clicks/events in my popup window from causing the rest of the application to become active? Or a way to let NSApp know that this particular panel shouldn't automatically activate the rest of the app? Thanks!
Instead of creating an NSWindow, create an NSPanel with the style NSNonactivatingPanelMask. You can then do the usual makeKeyAndOrderFront: and orderOut: to show/hide panel as needed.
NSApp's beginModalSessionForWindow, runModalSession, endModalSession are methods you need.
Have a look here for example how to use it:
Creating a fully customized NSAlert
A solution by Ken Thomases on the cocoa-dev list a couple years ago looks applicable here too:
[[NSApplication sharedApplication] hide:self];
[[NSApplication sharedApplication] performSelector:#selector(unhideWithoutActivation)
withObject:nil
afterDelay:0.05];
Which in theory tells the application to hide itself and unhide at the bottom of the window stack.
You could also intercept the mouse click event and use [NSApp preventWindowOrdering]
You can try something like:
...
if ([NSApp isHidden])
[myWindow makeKeyAndOrderFront:self];
else
[NSApp runModalForWindow:myWindow];
...
and when finish:
...
if ([NSApp isHidden])
[myWindow orderOut:self];
else
[NSApp stopModal];
...
I am running Xcode 4.3.3 and am targeting iOS 5.1. I am attempting to include Game Center functionality in a game.
When authenticating the GKLocalPlayer the user is presented with the Sign in to Game Center alert view or shown to be logged in. So far this is all fine, but if the user presses the Create New Account button then any open modal views are moved behind the root view controller and the following error is spit from the console:
Unbalanced calls to begin/end appearance transitions for
<GKModalRootViewController: memory address>.
I have tried moving the GKLocalPlayer authentication code between the app delegate and the root view controller. I have also tried implementing the authentication in a new, blank project. I have tried it with and without Storyboards and ARC. In all of these cases the results were the same: modals hidden behind the root view controller and error given.
Here is the GKLocalPlayer authentication method I am calling from my app delegate’s application:didFinishLaunchingWithOptions: method:
- (void)authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error) {
if (localPlayer.isAuthenticated) {
// Perform additional tasks for the authenticated player.
} else {
// Disable Game Center features.
}
if (error) {
// Handle error.
}
}];
}
Here is a screenshot of it. In this picture the root view controller has a background with a 50% alpha value. The modal has been pushed behind the root view controller by this bug.
This stackoverflow question contains the only reference to this error (regarding GKModalRootViewController) I can find, and it doesn't fit since (a.) I’m not using cocos2d. (b.) It happens whether or not I perform a segue, and I am not touching viewWillAppear: or viewDidAppear:. (c.) No acceptable answer was given.
This question and this one seem to involve the same issue (with the view hierarchy being destroyed) but are unanswered and don’t mention the console error message.
Does this happen for anyone else? Any ideas on what could be causing this?
UPDATE 1: I went so far as to put the authentication code into an IBAction connected to a button in the modal view so as to avoid any initialization conflicts. It didn't help.
UPDATE 2: I tried moving the authentication code into a GCD background queue. he results were the same.
Here is the test project (which is GameCenter ready with my app's Bundle ID already entered).
To test:
Log out of Game Center on the test device/simulator (if you are
logged in).
Build and run the app.
Press the info button.
Press Authenticate.
When the Sign in to Game Center alert appears press Create New
Account.
Press Cancel.
Did the “Unbalanced calls...” message appear in the console? Did the
modal view (with the Authenticate button) disappear?
Press the info button.
Did the modal display again?
This bug appears on the list of "bugs Apple fixed in 6.0". I understand you would love a workaround, but when its the APIs you depend on that are buggy, chances of that are slim.
You can however rejoice that 5.x users are slowly dying out.
Best of luck with your app.
I have a problem with a navigation controller.
First of all, there is a navigationviewcontroller.
Also, there is A webviewcontroller-containing view controller, meaning that webview controller is loaded inside WEBcontroller.m
I made that when the WEBcontroller is loaded, it automatically loads google.com. The function is in the -viewDidLoad()
First, when the app is launched, navigationview loads WEBcontroller.m, then WEBcontroller loads google.com as intended.
Then, when I click any link in the google.com, navigationview pushes a new view with
[self.navController pushViewController:newWebController animated:YES];
[newWebController gotoUrl:[request.URL absoluteString]];
It, of course, works. The newly loaded(and alloc) WEBController.m loads gmail.com by calling "gotoUrl" function.
And, I click another links to go "gmail.com/help"
So,
google.com -> gmail.com -> gmail.com/help
Then, I close the app, and play some games... it makes iPhone free memory.
Launching the app again, the "gmail.com/help" webpage is shown. Then, I click the [Back] button which is at the navigationBar which calls [popViewController].
Then, the navigation controller properly go back to preceding WEBController.m which was showing "gmail.com" page.
BUT!! there is a problem. Because the memory was 'dealloc' by iPhone, the WEBController is loaded AGAIN with "google.com" page, not "gmail.com" page.
I've searched this problem but I couldn't get any.
Really thank you for reading and giving some interests to my problem.
I'm confused. You are using a UIWebView? If so, why don't you just let it handle the links/navigation? Why are you creating (and pushing) a new UIWebView for every link click? Technically speaking, a view controller needs to be able to handle being freed and restored from memory by IOS. This is done in viewDidLoad and viewDidUnload. But I don't think that's what you want/need here.
I'm making an application based on TabView Template. In the appdelegate, I've replaced the codes from applicationDidFinishLaunching method, I removed UITabView from it and replaced it with a new View. That view is actually a login screen which appears as soon as the app launches. Now, after successful login, I want the app to switch to UITabView. I tried these codes but they didn't work. :(
Nothing happens when user successfully logs in.
Here's the code I'm using:
NSArray * spanNodes = [bodyNode findChildTags:#"form"];
for (HTMLNode * spanNode in spanNodes) {
if ([[spanNode getAttributeNamed:#"action"] isEqualToString:#"foo"]){
[self.authView.view removeFromSuperview];
[window addSubview:self.tabBarController.view];
[window bringSubviewToFront:self.tabBarController.view]; //Answer to second question
}
}
You don't need to remove the tab bar controller, it's far easier to just leave it in place and push the login screen to be on top of it, covering the tabs until login is successful, as described in an answer to a related question here: Adding login screen in front of Objective C Tab Bar Application for IOS