I am using phonegap version 2.2.0 and have installed ChildBrowser plugin code to XCode project, plugin loads fine with no problem. When navigating to a static html page in the main view which has bunch of tags and each tag has link to external page. Once you click that external link the ChildBrowser loads as expected, but when I close the ChildBrowser by clicking "Done" button the original view is there as expected. but when you try to scroll in that main view the scrolling part quits working, I am no longer able to scroll that page? I added following [[self parentViewController] reloadInputViews] line and thought that may solve the issue, but the problem still remains. Also, it whacks out the original stlye meaning the buttons and font looks larger. Some how the original webview needs to maintain it correct state. Please suggest any corrections.
I was looking at the close button event code
\Plugins\ChildBrowserViewController.m
- (void)closeBrowser
{
if (self.delegate != nil) {
[self.delegate onClose];
}
if ([self respondsToSelector:#selector(presentingViewController)]) {
// Reference UIViewController.h Line:179 for update to iOS 5 difference - #RandyMcMillan
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
[[self parentViewController] reloadInputViews];
}
}
Related
I have no idea where to even start trying to fix this but maybe someone can point me in the right direction. I have a status item application that shows a popover when clicked, some user interactions produce an NSUserNotification to warn/inform about changes or errors. But when the notification appears it is shown behind the popover, so if they overlay the user can't read what it says.
Is there a way to force the notification to appear in front of the popover? Like order the notification to the front.
Edit: here's a picture showing part of the notification hidden behind the popover after a user gave bad input. I don't really want to hide the popover to show the error notification.
I've tried stuff lake makeKeyAndOrderFront, activateIgnoringOtherApps, the type of stuff you'd use on a window, but none of it applies to an NSUserNotification so it doesn't work.
Edit 2: I should note that to get the popover to appear in front of everything when called I use activateIgnoringOtherApps and becomeFirstResponder on the popover, but even getting rid of that still shows the notification behind the popover.
Edit 3: The popover is shown relative to a status item in the status bar using
[[self popover] showRelativeToRect:statusItem.view.bounds ofView:statusItem.view preferredEdge:NSMaxYEdge];
When clicked, the status item calls a method that does this:
- (void)openPopover:(id)sender {
if (![_popover isShown] | (_popoverIsClosing)) {
[_preferencesWindow close];
[NSApp activateIgnoringOtherApps:YES];
[_popover becomeFirstResponder];
[statusItemView setHighlighted:YES];
[[self popover] showRelativeToRect:statusItem.view.bounds ofView:statusItem.view preferredEdge:NSMaxYEdge];
[self performSelector:#selector(defaultTextField)];
NSLog(#"popover opened");
} else {
[_preferencesWindow close];
[NSApp activateIgnoringOtherApps:NO];
NSLog(#"popover closed");
[_popover close];
[_popover resignFirstResponder];
[[NSApplication sharedApplication] hide: self];
[statusItemView setHighlighted:NO];
}
}
Thanks for the help.
You want to adjust the window.level.
A notification is using level 18, so as long as your level is lower, you will not have this issue.
You can use these default NSWindow.Level
.normal = 0
.floating = 3
.submenu = 3
.tornOffMenu = 3
Or a custom level NSWindow.Level(rawValue: 17).
An important thing to note is you should set the windows level during or after the popover did show. Otherwise your setting will be reset.
You can do this from the popover.delegate using the function,
func popoverDidShow(_ notification: Notification)
Or listen to the notification directly with NSPopoverDidShowNotification.
This has been tested on macOS 10.15
Ive got this code and everything works correctly. But when I'm testing my app the switch is really hard to turn over on the UI.
-(IBAction)mySwitch:(UISwitch *)sender {
if([_theSwitch isOn]){
[_theSwitch setOn:NO animated:YES];
}
else if (![_theSwitch isOn]) {
[_theSwitch setOn:YES animated:YES];
}
}
is there any way that I can make it like the iOS 7 settings switches where it toggles on and off by button press rather than slide?
The reason is the code you've added. There is no reason to tell the switch which state it is in. It knows that info already. Remove all of that code and it should solve the issue.
I'm struggle at this for 2 days and believe that this is the moment I should call for help. After I search SOF for a while, none of any answer could solve my problem. Here are my application ...
In the application,
Device is iPad, iOS 6
RootViewController is NavigationController
TopViewController is TabBarController
In this TabBarController, I present a popoverController from right bar button of navigation bar
In presenting popover there is a button to allow user to pick image from by taking new one or pick from existing.
To pick new one, I presentViewController UIImagePickerController to allow user to take photo with divice camera. presentModalViewController:animated: if iOS < 6, and presentViewController:animated:completion: for iOS > 6
I also hide Status Bar before presentation
To select from existing photo, I do presentPopoverFromBarButtonItem:permitArrowDirections:animated:
PopoverViewController also referencing by A TabBarController
Here is the issue
Present UIImagePickerController will always failed if user try to pick new one first with exception "Application tried to present modally an active controller <[name of view controller that try to present]>"
BUT, if user try to pick image from camera roll for once and then try to take new one again, it won't fail.
Here are what I tried
present from RootViewController
present from TopViewController (TabBarController)
present from popoverViewController itself
present from a tab of TabBarController
hide popoverViewController before presentation
resignFirstResponder from a textField in popoverViewController
Here is the current code I'm using
// PopoverViewController, presented by a tab in TabBarController
- (IBAction)takePhoto:(id)sender {
[self.delegate takePhotoWithDeviceCamera];
}
// A Tab in TabBarController, delegate of popoverViewController
- (void)takePhotoWithCamera {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
if ([UIDevice OSVersion] < 6.0) {
[self presentModalViewController:cameraPicker animated:YES];
} else {
[self presentViewController:cameraPicker animated:YES completion:nil];
}
}
Any idea what would cause this error? Any suggestion are welcome. Thank you.
Got the same trouble than you and finally got the solution based on #CainaSouza's answer. I've been working with Xamarin.iOS so I'll make my answer in C#, but it can be easily translated to Objective-C.
I'm using the same code as #CainaSouza to call the controller:
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (customController, true, null);
And then I add the following code to my custom RootViewController:
public override void PresentViewController (UIViewController viewControllerToPresent, bool animated, Action completionHandler)
{
if (PresentedViewController != viewControllerToPresent) {
base.PresentViewController (viewControllerToPresent, animated, completionHandler);
}
}
The trick is to check if you haven't presented that UIViewController before.
I know it's an old question, but hope it will help someone. :)
Present the imagePicker controller in a popoverController(in case of iPad). This will not give you that error.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popOver = popover;
}
else {
[self presentModalViewController:picker animated:YES];
}
Best Regards.
Have you tried to present it like this?
[self.view.window.rootViewController presentModalViewController:cameraPicker animated:YES];
My guess is that the cameraPicker instance is not correctly allocated/released. Try creating the cameraPicker inside your - (void)takePhotoWithCamera method rather than relying on a previously created instance. You'll get a handle to the picker instance in the callback methods...
I had the same problem - I wanted users to take photos using a full screen view (i.e. call presentViewController and pass UIImagePickerController controller instance) and select existing photos from a popover (I associated it with a popover using initWithContentViewController). I reused the same instance of UIImagePickerController for both camera and popover and it threw the same exception if I tried to run a camera before opening a popover.
I turned out to cause a problem and my solution was simply to have two instances of UIImagePickerController - one for camera (which I presented from a main view) and another one for popover. It works so far. :-)
Not sure if it is still actual for the original poster, but hopefully it will help anyone else who encounter this discussion.
I'm manually invoking a segue (set as modal) in order to display a login form in Xcode 4.2 using Storyboards with the following line of code:
[self performSegueWithIdentifier:#"LoginSegue" sender:nil];
I'm probably missing something really simple, however I can't find a way to programmatically close the login view and return to the previous view.
The view is part of a navigation view controller, so setting the segue type to "push" allows me to use the back button to send me back to my previous screen, but in "modal" mode, I'm not entirely sure how to achieve this (after button press, for example)
Any help would be much appreciated.
If your deployment target is iOS 5.0 or later, use this message:
[self dismissViewControllerAnimated:YES completion:nil];
Or in Swift:
self.dismissViewControllerAnimated(true, completion: nil)
If your deployment target is older, use this (deprecated) message:
[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil]; is a new way in IOS5
The following should work fine...
[self dismissModalViewControllerAnimated:YES];
I do exactly this with a login page in my latest tutorial here, with no issues.
The following code works in swift 3:
self.dismiss(animated: true, completion: nil)
I am trying to present a modal view in a tabbar app. I am using the code
- (IBAction)newView
{
[self.viewController presentModalViewController:viewController
animated:YES];
}
linked to a button. When the button is pressed, nothing happens and nothing is displayed on the log. This is most likely simple to fix, but I have not found anything that has worked yet.
Thanks
Use this and you rock:
[self presentModalViewController:viewController animated:YES];