There is a button at bottom right of iPad keyboard which is to hide the keypad.
How can I interact with it programmatically? (get the button then send UIControlEventTouchUpInside to it).
Does anyone know this?
[Edit]
In my case, the keyboard is shown on a modal view.
Overriding disablesAutomaticKeyboardDismissal to return NO as below allows you to dismiss the keyboard when you resignFirstResponder, even when your UITextView is on a modal view. You should put this code to your view controller, from which you initiate the keyboard:
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Source: https://stackoverflow.com/a/6268520
In general, you would send the resignFirsResponder message to the active input view.
Something like this? I can't remember where I found this code but I used it to toggle the on-screen keyboard because it would be hidden by default if a bluetooth one was connected.
- (void) toggleKeyboard(UIKeyboardImpl * keyImpl){
if (UIKeyboardAutomaticIsOnScreen()) {
UIKeyboardOrderOutAutomatic();
} else {
UIKeyboardOrderInAutomatic();
}
Edit
I found where I got this code from. It works fine but the catch is that you need to import the private framework GraphicsServices, which would most likely get your app rejected from the App store.
Related
I want to have effect like VLC Play Pause Button. Based on other posts, I have
Have created resource file with play pause icons(transparent background).
Have created checkable toolbutton through qt designer.
Have assigned icon for normal off/on through qt designer.
However, when I run the application and click button(IsCkecked is true), the icon turns slightly grey. I do not want background color to change. I am not sure, what is causing this behaviour as well.
Does anyone know reason behind this?
Thanks in advance.
Set stylesheet to the play button.
Like this...
QPushButton
{
background-color:#fffff;
}
QPushButton:pressed
{
background-color:#fffff;
}
Set stylesheet to the play button.
Like this.....
QPushButton
{
background-color:#fffff;(this color can be changed as you want)
}
QPushButton:pressed
{
background-color:#fffff;( same as above )
}
Is it possible to detect when the Today widget is expanded/contracted or 'Show More' button is tapped in Objective C?
There is no way to detect whether the Show More button has been tapped in Today Extension.
What you can do is determine if it's open with checking frame height.
You can add a boolean and set it in :
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize {
if (activeDisplayMode == NCWidgetDisplayModeCompact) {
//non expanded
} else {
//expanded
}
}
You can also have a layout that doesn't need to know if it's opened or closed, that's what most apps do.
Hope this helps :)
Hi... I am having an app in which I am using UIAlerController to show alert view.
I am sucessfully able to show it but the problem is I can not dismiss the view on touching outside. I have to create a view manually and a cancel button (shown in screenshot).
I know I can get the touch with putting Uialertactionstyle cancel but that makes my UI improper.
So Is there any other way so that I can get the touch event on outside touch?
Thanks in advance.
I try to use xcode tool to see the view hierarchy ,and it looks like as below:
I find the correct view to add tap gesture,so I modify the code and it works.
UIAlertController alert;
partial void UIButtonTouchUpInside(UIButton sender)
{
alert = UIAlertController.Create("title", "msg", UIAlertControllerStyle.ActionSheet);
this.PresentViewController(alert, true, () =>
{
UITapGestureRecognizer tap = new UITapGestureRecognizer(tapAction);
alert.View.Superview.Subviews[0].AddGestureRecognizer(tap);
});
}
void tapAction()
{
alert.DismissViewController(true, null);
}
I try to implement a custom ContextMenu in a LongListSelector.
I'm not using the ContextMenu from Microsoft.Phone.Controls.Toolkit, it's basically the same as in the Rowi App:
(source: hiddenpineapple.com)
Approach 1
My list item toggles a VisualState on hold and an overlay is shown with controls in it.
The problem
I can't find a way to go back to the default state when the user clicks outside of the list item (as in the default ContextMenu).
Approach 2
I've implemented a custom template for the toolkit ContextMenu which looks exactly the same. I had to move its margin top to -itemHeight, as by default it is below the item.
The problem
The problem with this solution is, that it automatically closes itself when opening and I couldn't figure out how to avoid this.
Another problem was that it didn't work well with TiltEffect.IsTiltEnabled from the Toolkit (visual problems).
I need your help
Any suggestions on how to get this working?
Answer
Thanks to Cheese, now I know how to properly close the menu when the user clicks outside.
His suggestion was to get the coordinates of a Tap event on the current page, and check if it's inside the menu. When not, close the menu.
So I added a Tap listener to the page when the menu opens, and removed it when the menu closes. From the page listener I got the event coordinates and could check if it's inside the control which holds the menu (same size and position). I received the position of the control with Point leftUpperPoint = control.TransformToVisual(page).Transform(new Point(0, 0)) and the rightLowerPoint by adding the ActualWidth and ActualHeight.
But then I realized:
Why should I even calculate if the tap is inside the menu? I always want to close the menu when the user taps anywhere on the screen. If it's outside, yes. If it's on a menu button, yes.
Another modification I made was to listen for MouseLeftButtonDown instead of Tap as it also triggers when the user swipes.
So I removed this code and came up with the following:
private void ToggleMenu(object sender, System.Windows.Input.GestureEventArgs e)
{
PhoneApplicationFrame frame = ((PhoneApplicationFrame)Application.Current.RootVisual);
VisualState state = this.States.CurrentState;
if (state == null || state.Name == "DefaultState")
{
frame.MouseLeftButtonDown += MouseDownDelegate;
this.State = "MenuState";
}
else
{
frame.MouseLeftButtonDown -= MouseDownDelegate;
this.State = "DefaultState";
}
}
private void MouseDownDelegate(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
ToggleMenu(sender, null);
}
This works perfectly!
Thanks to Cheese for the hint.
Something like this by #denniscode http://dotnet.dzone.com/articles/rowi-show-tap-menu
Approach 1 problem
The best solution would be:
Get the menus coordinates, when user makes a tap - you check are tap coordinates on menu or not, if not - dissmiss - simple.
Approach 2 problem
I guess you had some button in a corner and when you tapped on it - nothing happened? And when you dissmissed the Tilt all worked. It seems that tilt works faster than a click, so, tilt changes the button coordinates, and device thiks you have missed/or dragged off
You can use what #ScottIsAFool suggested and maybe create another Dependency Property on your TapMenu control of type UIElement named CloseWhenTappedElement and automatically listen for Tap events inside your control once set. For example
<Grid x:Name="TapArea"/>
<TapMenu CloseWhenTappedElement="{Binding ElementName=TapArea"}/>
How can I override the functionality of browser's back button? I have navigation view in page and I want to synchronize the browser back button and navigation view's back button. I can override navigation button's functionality but I don't know how to do the same thing for browser back.
Any help will be appreciated.
You have to use routes, this tutorial will show you how: http://railsdevtricksofthetrade.blogspot.com/2012/04/sencha-touch-2-routes-and-back-button.html?m=1
I managed to override the back button of the nav view with the following code
In your controller, create a new ref:
backToNav: 'myNavXtypeName button[text=Back]'
In the same controller, link the ref to a control:
backToNav: {
tap: 'backToNav'
}
Finally create the controller method that implements the navigation view's pop functionality.
backToNav: function() {
Ext.getCmp('myNavXtypeName').pop()
}
Done.
Read more about refs and controls here