Why iPhone X InputViewController height is like half of system keyboard size? - ios11

I am testing custom keyboard extension in iPhone X. I just created a new project with Keyboard extension. As you see in 2 photos , custom keyboard's height is like only a half of system keyboard's height. I don't know why. Is there any way to get actual keyboard height like system keyboard height?
Custom Keyboard
iOS System Keyboard

Here you go. Write this piece of code in viewDidAppear.
CGFloat _expandedHeight = 500; //The height you want
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem: self.view
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 0.0
constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
In iOS 8.0, you can adjust a custom keyboard’s height any time after its primary view initially draws on screen.

Related

ToolStripDropDownButton does not show items when right aligned

I developed a Winforms application that has a Toolbar. The last element in the toolbar is a ToolStripDropDownButton with some items.
I needed this button to be shown apart from all other toolbar buttons, so I set the Alignment property to right.
In my PC this works perfectly, however, when I moved the whole Visual Studio project to my notebook and then ran the application, the menu items are not shown when I click the button, however, the dropdown button changes color indicating that it was selected.
At design time, items are shown correctly.
What is happening here and is it possible to solve it? At the moment, I set the button alignment to left, so that it is shown together with other toolbar buttons.
Thanks
Jaime
Check your DPI settings on your notebook. It is likely changing the size and padding of your elements. You can get around this by checking for the system's DPI value and calculating sizes of controls based on that.
var graphics = this.CreateGraphics();
var dpiX = graphics.DpiX / 96d; // Default DPI
var dpiY = graphics.DpiY / 96d; // Default DPI
myToolbar.Width = myWidth * dpiX;
myToolbar.Height= myHeight * dpiY;

Image displaced or absent with ImageViewer

Using the designer. My form has a layout BoxLayoutY. I just drop the ImageViewer in it. I have a pic added through "Add Picture", which is 1080 x 1400. I add it to the ImageViewer.
The "Simulate Device" command gives, in iPhone3:
And in Nexus (the pic below is static: can't be scrolled up or down):
Help?
I have installed the app locally on my Android and I get the same half cut pic as in the screenshot of the Nexus simulator.
The overal goal is to have a single form, scrollable vertically, showing pics (adjusted at the width of the screen) and text.
EDIT:
Could be a problem with the resolution of the pic. I decrease the res to 350 x 467 and it displays fine. So it will pixelize or won't scale to fit the width of the screen on larger devices?
The image viewer doesn't have a preferred size since it doesn't have an image in it. Its designed for usage full screen or within a predetermined layout. If you place it in the center of a border layout it will take up available space and work as expected.
Since it scales the image and allows manipulation of that images size, its size is flexible. If you want a component that takes up the exact image size you should use a Label.
Ok got it!
What I was doing wrong was that I had:
MainForm (in a BoxY layout)
-> a container nested in it (in Borderlayout)
---> an ImageViewer nested at the center of it.
This produced the effect above (half cut pic).
Instead, what achieved a properly sized pic was:
MainForm (in a BorderLayout).
-> The ImageViewer nested at the center of it. That's it, no container.

Rotate WPF control or change screen orientation

I have wpf project with one Window (MainWindow). Depending upon the config file it shows one of two UserControl's as Content. It may be a horizontal (1920x1080) control or vertical (1080x1920) control. It's fine with horizontal screen, but when vertical is loaded I would like to do:
1) rotate window/control by 270 degrees
2) change primary screen orientation
I would prefer to just rotate application and don't interact with windows API. I can't change orientation manually, because I have only remote access to this computer.
You can not rotate the Window object itself, as it is positioned by the window management system built in Windows. You can, however, transform (and thus rotate) any FrameworkElement inside the window. This includes, but is not limited to, the Grid, the Button and the TextBox elements.
All you need to do is edit the LayoutTransform property on the element you want to rotate, which is most likely the root element in your window. Set the rotation to 270/-90 degrees and WPF will automatically rotate your UI.
Because you are using the LayoutTransform property, the layout system will also scale you UI correctly. The RenderTransform property causes the control to first be rendered, then be rotated.
YES WE CAN CHANGE SCCREEN ORIENTATION USING
DEVMODE & using System.Runtime.InteropServices;
its bit late to reply but I am replaying for the new ones , if someone com across this article for change screen rotation in C# or VB .
Please use the link given below to get help Mr. Hannes Completely write an article to change screen rotation and luckily its working fine for me (Windows 11) as now of..
https://www.codeguru.com/dotnet/creating-a-screen-rotator-in-net/

wpf notifyicon context menu not centered on tray icon at 100% dpi

I'm using the wpf notifyicon (http://www.hardcodet.net/wpf-notifyicon)
When my laptop is at 100% dpi scaling, the left side of the context menu is centred on the tray icon, as expected.
When the laptop isn't at 100%, the context menu is pushed to the far right.
On high resolution laptop displays, 100% scaling is not the default.
Wherever my tray icon is positioned, that is, however far from the clock, the menu always pops up over the clock, as far to the bottom-right of the screen as is possible while remaining visible.
Note: I'm testing on a default installation of Windows 8.1. Also, the NotifyIcon that I'm using is the one that is generally recommended for anyone attempting tray functionality in WPF.
To reproduce: the problem exists in the windowless sample provided by hardcodet. I'm using wpf NotifyIcon without a window, and can reproduce easily in code or xaml. In fact, I cannot stop reproducing it. It occurs when dpi scaling is turned on, i.e. when a 1080p display is actually showing a lesser resolution, which is what windows does to stop applications having text too tiny to read.
Any ideas about how I can make the context menu appear in the expected place regardless of dpi?
Screen shots as suggested by kennyzx:
good behaviour. the m on red background (MEGAsync) has just been right-clicked
bad behaviour. the green tick, my notifyicon, has just been right-clicked and the menu appears over the clock
!good behaviour. the m on red background (MEGAsync) has just been right-clicked
!bad behaviour. the green tick, my notifyicon, has just been right-clicked and the menu appears over the clock
and some code:
var n = new TaskbarIcon();
n.Icon=new System.Drawing.Icon(#"C:\window - 64 - tick.ico");
n.ContextMenu = new System.Windows.Controls.ContextMenu();
n.ContextMenu.Items.Add(new System.Windows.Controls.MenuItem {Header="E_xit" });
Found the solution here: http://www.codeproject.com/Messages/4929452/Problem-with-context-menu-position.aspx
It is, with thanks to codeproject user Igorious:
Get the code for Wpf Notifyicon (http://www.hardcodet.net/wpf-notifyicon)).
In Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.ShowContextMenu()
replace
ContextMenu.HorizontalOffset = cursorPosition.X;
ContextMenu.VerticalOffset = cursorPosition.Y;
with
var g = Graphics.FromHwnd(IntPtr.Zero);
var scaleX = g.DpiX / 96.0;
var scaleY = g.DpiY / 96.0;
ContextMenu.HorizontalOffset = cursorPosition.X / scaleX;
ContextMenu.VerticalOffset = cursorPosition.Y / scaleY;
Explanation (thanks to codeproject user yachting):
It's needed because WinApi.GetPhysicalCursorPos return the mouse position in pixel,
but WPF's measurement unit is device independent pixel (by definition, it's 1/96 inch)
You need to adjust the return value of GetPhysicalCursorPos by DPI (dots per inch) setting,
otherwise the position of the context menu will be incorrect if users set DPI other than the default 96.

How to resolve the orientation of ImagePicker control view in landscape mode and whole application in portrait mode?

What I want is my whole application is in portrait mode only.
And it working fine in ios 6+. The only support required at now.
But the problem is I need to launch UIImagePickerViewController with image source type camera in only landscape mode.
What I tried till now is:
(1) I try to create one category for UIImagePickerController for orientation.
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Like this. But the camera view is not proper aligned. It just follows the orientation of device with some +/- 90 angle but not what I required.
Even the button of the camera shown by camera view as camera control is also follows the camera view, ie. the view is rotated to 90 anti clock vise and stays to that way.
I use the below code to present the image picker view controller
[self presentViewController:imagePicker animated:YES completion:nil];
Is there any way to use the camera with proper alignment? or have to use other framework to work with it?

Resources