In iOS 13.2, I'm noticing that my keyboard no longer shows up in my apps on the simulator and a real device. When I tap inside a UITextField, nothing happens but the cursor blinking inside the textfield. Is anyone else having this problem or know how to solve?
UPDATE
The problem originates from removing storyboard files and initiating a rootViewController programmatically
var windowScene = new UIWindowScene(session, connectionOptions);
Window = new UIWindow(windowScene);
Window.RootViewController = new ViewController();
Window.MakeKeyAndVisible();
After that, I just noticed the keyboard doesn't show again in a new project.
This looks like a bug when you try use a programatic approach to setting a rootViewController in the new SceneDelegate opposed to how we used to in AppDelegate.
I got around this by keeping the dumb storyboard which sets the rootViewController inside and keeping SceneDelegate.cs clean for the moment and my keyboard works again. Thanks for all your answers.
set textfiled delegate.
#IBOutlet weak var urlTextField: UITextField!
override func viewDidLoad() {
self.urlTextField.delegate = self // urlTextField it is your textfield outlet
}
If you delete this line of code, the keyboard does not appear, but if this exists, the keyboard does come up.
About simulator : You can check setting in iOS simulator firsrt .
Have a look at this screenshot ,be sure Use Hardware Keyboard not be selected . Or you can select it and unselect it again , then keyboard will show.
Restart app to check whether keyboard can be shown.
Related
On Windows 10, the ShowBalloonTip method of NotifyIcon NEVER shows the balloon tip. This would appear to have something to do with Windows itself.
If I go to Settings > System > Notifications & actions > and find my running app (vshost32.exe in debug mode) and click on it, then turn on Show notifications in the action center, I can clearly see the balloon tip messages being added to the notifications, but never a balloon tip.
I assume this is a problem with Windows 10.
My NotifyIcon is VISIBLE
my_icon.ShowBalloonTip("Title", "Message", BalloonIcon.Info);
On my computer with Windows 10 version 1803, go to Settings > System > Notifications & actions, and turn on "Get notifications from apps and other senders".
The ballontips from my WPF app will show up.
Found the problem - was simple: Quiet Hours was turned on in the notification center and this was preventing the balloon tips.
Turn off Focus Assist. If you are using second screen, turn off "When I'm duplicating my display" option. My settings is like that:
I've fixed the problem by adding icon property. If this property isn't set, the baloontip won`t be shown. Here's example of my code:
var notify = new NotifyIcon();
notify.Visible = true;
notify.Icon = new System.Drawing.Icon(#"D:\Users\User\Desktop\some.ico");
int code = new Random().Next(1000, 9999);
notify.ShowBalloonTip(500, "code", $"{code}", ToolTipIcon.Info);
Neither of these solved my issue :(
But by accident I fixed it! My problem was I had my project configured for 32-bit on a 64-bit platform and for whatever reason they only show up when when I run the project for Any CPU (64-bit in this case)!!
Hopefully that helps some of you, it was a real mystery for me...
(I also posted this answer here because these are duplicate questions)
Change the Solution Configuration "Debug mode to Release mode" with X64 or X32 Solution platform. It will start work.
public static NotifyIcon trayIcon;
trayIcon = new NotifyIcon();
trayIcon.Icon = new Icon("Images/Test.ico");
trayIcon.Visible = true; trayIcon.Text=Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName);
ContextMenu contextMenu1 = new ContextMenu();
contextMenu1.MenuItems.Add("Menu2", Menu2_Event);
contextMenu1.MenuItems.Add("Menu3", Menu3_event);
contextMenu1.MenuItems.Add("Exit", Close_Click);
trayIcon.ContextMenu = contextMenu1;
trayIcon.BalloonTipText = "Hi Test";
trayIcon.ShowBalloonTip(1000);
Just for reference, as #rmirabelle wrote in the question "My NotifyIcon is VISIBLE". This is actually important.
If the notification icon is not visible in the systray, the BalloonTips won't show up either.
Possible sources for invisibility are:
Visible property = false
No icon is set for the NotifyIcon object
I have a C# WinForms application, when you press a button at run-time, the application has to play a video but not in another new window, I want it to be in the form itself, also I don't have to see the Play/Pause/Stop etc. buttons of the Windows Media Player, just to have the video playing and when it ends return to the beginning where the button is situated. I couldn't find a question similar to this one, anyone has any ideas ? If any more information is needed just let me know.
Thanks alot!
Using Windows Media Player Control:
You can hide control buttons by setting uiMode property to none.
You can enable loop mode using settings.setMode method and setting loop to true
You can set a file path to play, by assign a path to URL property.
Since the settings.autoStart property is true by default, when you set the url, the player plays the media. Also you can use commands like Ctlcontrols.play or other control commands.
Sample Code
this.axWindowsMediaPlayer1.uiMode = "none";
this.axWindowsMediaPlayer1.settings.setMode("loop", true);
this.axWindowsMediaPlayer1.URL = #"d:\video1.wmv";
Resources
How to: Embed Windows Media Player on a Form
AxWindowsMediaPlayer Object Properties, Methods and Events
I have and windows app and I want that my app icon will always show in system tray. As now it will hide after time. Please help me to solve my problem. Thanks in advance.
Code of System tray App:
NotifyIcon ni = new NotifyIcon();
// Put the icon in the system tray and allow it react to mouse clicks.
ni.MouseClick += new MouseEventHandler(ni_MouseClick);
ni.Icon = Resources.favicon;
ni.Text = "***";
ni.Visible = true;
// Attach a context menu.
ni.ContextMenuStrip = new ContextMenus().Create(ni);
ni.BalloonTipText = "abc...";
ni.BalloonTipTitle = "abc";
ni.ShowBalloonTip(5000);
I guessing a little, but I think the issue is that the user has chosen a UI option that hides notification icons to avoid the notification area taking over the taskbar.
There is no supported way for you the programmer to indicate that your notification icon is so important that it must show all the time irrespective of the wishes of the user. The user gets the opportunity to indicate that certain icons are always to be shown. Right click in the notification area and select Customize notification icons. This allows the user to decide which icons are always visible.
So, you the programmer do nothing. You let the user make the choice.
I am trying to create an application that will have a tray icon only, and not appear in the taskbar. (similar to Dropbox) I need to create both Windows and Mac version of the application, so I tried using MonoMac to create the Mac front-end.
What is the best way to create a tray-only application in MonoMac?
All the resources I have found say to do one of two things:
Add <key>LSUIElement</key><string>1</string> to the Info.plist file.
Add the following code to the FinishedLaunching event in the AppDelegate class: NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Accessory;
I have tried all combinations of these two, but it seems that as soon as I try to instantiate a C# System.Timers.Timer, the icon reappears in the dock at the bottom of the screen. Am I missing something about how OSX handles background applications?
What am I doing wrong? Is there a better way to make a background application that has an upper tray icon but no bottom dock icon in OSX?
(This is very similar to this SO question, but that question was from a couple years ago and was never fully answered, so I'm hoping there might be a more complete answer out there.)
Here's the code I have so far:
public partial class AppDelegate : NSApplicationDelegate
{
MyServiceObject currentServiceObject;
public AppDelegate () { }
public override void FinishedLaunching (NSObject notification)
{
// Construct menu that will be displayed when tray icon is clicked
var notifyMenu = new NSMenu();
var exitMenuItem = new NSMenuItem("Quit My Application",
(a,b) => { System.Environment.Exit(0); }); // Just add 'Quit' command
notifyMenu.AddItem(exitMenuItem);
// Display tray icon in upper-right-hand corner of the screen
var sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
sItem.Menu = notifyMenu;
sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(
NSBundle.MainBundle.ResourcePath + #"/notify-icon.icns"));
sItem.HighlightMode = true;
// Remove the system tray icon from upper-right hand corner of the screen
// (works without adjusting the LSUIElement setting in Info.plist)
NSApplication.SharedApplication.ActivationPolicy =
NSApplicationActivationPolicy.Accessory;
// Start running the program -- If I comment out then no dock icon appears
currentServiceObject = new MyServiceObject();
}
}
I found the problem, and it wasn't related to the application settings at all. Evidently, there are some operations that MacOS does not allow an 'Agent applications' to perform. As soon as one of those methods is called, the application is forced to appear in the dock. The code that was tripping up my application was a call to:
System.Windows.Forms.Cursor.Position.ToString()
Removing that line, and replacing it with the following MonoMac method allowed the application to remain hidden:
NSEvent.CurrentMouseLocation.ToString()
I was able to get this working by setting the value of "Application is agent (UIElement)" key to 1 in the info.plist file. Even though it should be a BOOL value, MonoDevelop makes it a string, but setting it to 1 seems to work. You can also set an empty string the for the "Icon file" but it's not necessary.
I'm building a MonoTouch iPhone app, but have come up with a small issue.
I have a view with 2 UITextFields for login (username/password), however when I first tap on a field, it pops up the keyboard, and the keyboard never disappears again.
The problem is the keyboard hides my "Login" button, so the user cannot tap it.
I'd like the keyboard to resign if I tap anywhere on the "background" of my view.
So I figured out I can do that in TouchesEnded on my UIViewController - however to resign the keyboard I need a reference to the current UIView being FirstResponder.
Which finally leads to my question: Can I find out which UIView is currently FirstResponder without looping recursively through all views from my UIViewController ?
You can use
this.View.EndEditing(true);