AcrUserDialogs Toast Position - c#

I'm using AcrUserDialogs on a Xamarin project. My problem is that I need to display a toast in the top of the screen. By default they are displayed in the bottom. I see that AcrUserDialogs toasts have a ToastPosition setting but I can't seem to find how to initialize that:
UserDialogs.Instance.Toast("Awesome message to user.");
I even downloaded the AcrUserDialogs repository code but I'm just stuck on this one.

You need to set the DefaultPosititon property in the static class ToastConfig.
Acr.UserDialogs.ToastConfig.DefaultPosition = ToastPosition.Top;
Acr.UserDialogs.UserDialogs.Instance.InfoToast("I should be shown at the top");

Related

Keyboard not showing when being prompted by UITextField

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.

Application title bar disappeared - UWP app

I have na uwp app (published in Windows/Microsoft Store), and the app title bar is normally this:
I was doing some tests in my app (to test the fluent design system) and I made some changes and I did not notice, because now it appears like this:
The name of my app has disappeared and the ellipsis (...) that is included in the header of the page also does not appear.
How can I resolve this?
It happened to me too exactly when I was testing fluent design system!
To recreate the issue. Simply Add
// Extend acrylic
extendAcrylicIntoTitleBar(); to OnLaunched at App.xamel.cs
Then add following code to App.xamel.cs
/// Extend acrylic into the title bar.
private void extendAcrylicIntoTitleBar()
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
ApplicationViewTitleBar titleBar =
ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
}
Next you need to fix the missing using by hitting Ctrl + . key.
At this point the title bar disappear. Even removing the extendAcrylicIntoTitleBar() function will not solve the issue!
The title bar will appear again if I remove following
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.ApplicationModel.Core;
I am not sure if it is a issue. That seems to be the way fluent design works
Above test is done according to
https://learn.microsoft.com/en-us/windows/uwp/design/style/acrylic#acrylic-theme-resources
The last value is cached in the registry. Try deleting this:
[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\<GUID_PublisherID>\PersistedTitleBarData\<GUID_PublisherID>!App]
"AppVersion"=hex(b):00,00,00,00,00,00,01,00
"ExtendViewIntoTitleBar"=dword:00000001
Also saved nearby is last window position, and splash screen info.

LayoutParams change only takes effect in fullscreen

im using Xamarin with MvvmCross.
Ive done a FragmentDialog with a recyclerView inside, the list is populated via bindings on xml file, so i have no adapter and i should keep it this way.
If im not wrong, theres no built in way to make the recyclerView take only the size needed for its content, this should not be a problem, but in this case i need the list to start from bottom...
So i did this (its a custom fullscreen dialog) :
MvxRecyclerView list = Dialog.FindViewById<MvxRecyclerView>(Resource.Id.recyclerview);
list.LayoutChange += List_LayoutChange;
Then in layoutChange
private void List_LayoutChange(object sender, View.LayoutChangeEventArgs e)
{
MvxRecyclerView list = Dialog.FindViewById<MvxRecyclerView>(Resource.Id.recyclerview);
int itemHeight = list.GetChildAt(0).Height;
if (itemHeight != 0)
{
ViewGroup.LayoutParams prms = list.LayoutParameters;
prms.Height = itemHeight * list.GetAdapter().ItemCount;
list.LayoutParameters = prms;
list.LayoutChange -= List_LayoutChange;
list.RequestLayout();
}
}
That was working fine, the list get exactly the height needed and the list looks like it starts from bottom.
Now the client tell me that he doesnt like the fullscreen dialog and wants the status bar, i think that should be easy, just to remove this line at the dialog creation right?
dialog.Window.AddFlags(WindowManagerFlags.Fullscreen);
But looks like its not that easy, when the dialog its not fullscreen the layoutParams change seems to have no effect, it just dont do nothing.
My method is being called and i get the right item height, it just dont change the recyclerview height.
Notice that setting fullscreen at creation and clearing the flag after the recyclerview params change works
So looks like it only works during fullscreen mode.
Can someone throw some light at this?
Thanks in advance.
As you said, RecyclerView was not aware of its size.
Since last update to the support lib, it is !
http://android-developers.blogspot.fr/2016/02/android-support-library-232.html
The RecyclerView widget provides an advanced and flexible base for creating lists and grids as well as supporting animations. This release brings an exciting new feature to the LayoutManager API: auto-measurement! This allows a RecyclerView to size itself based on the size of its contents. This means that previously unavailable scenarios, such as using WRAP_CONTENT for a dimension of the RecyclerView, are now possible. You’ll find all built in LayoutManagers now support auto-measurement.
I would suggest to wait for the Xamarin wrapped lib (there is already a beta https://www.nuget.org/packages/Xamarin.Android.Support.v4/23.2.0-beta1)

How to get a default iOS navigation back button

How can I get the default back button on an iOS UINavigationController? I have the button being added in code, but I want the default style. Is there an Enum of System Images that contains the '<', or is there not really a way, and Ill have to design my own?
Heres the code to make the button:
controller.DetailViewController.NavigationItem.SetLeftBarButtonItem (new UIBarButtonItem(UIBarButtonSystemItem.Stop, (sender, args) => {
controller.DetailViewController.NavigationController.PopViewController(true);
}), true);
Its written in C# using mono touch, and Xamarin.iOS, but I can work on porting Objective-c/Swift code if needed. Im just stuck at this point and can't seem to figure it out at all.
If you push your view controller then you will get default back button with navigation bar. If you don't want to push to push viewController then you need to add it on storyBoard. For pushing the view controller you write the code as
Your_ViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:#"Your_ViewController"];
[self.navigationController pushViewController:viewController animated:YES];

C# PresentViewController to a viewcontroller in storyboard

I am creating my first Xamarin-application (C#) in iOS and I am having trouble with navigating in storyboard. All of my tabbar-,navigation- and viewcontrollers are in the storyboard. In almost every viewcontroller, I added a menu (Facebook- and YouTube-style) which slides from the side. From there it has to be possible to return to the first viewcontroller (home) in storyboard. Because the menu is active in almost every controller of my application, I don't use segues (It would be a mess in my storyboard).
So I would want to use PresentViewController(), but when I do this, the page turnes black and doesn't show anything.
homeViewController home = new homeViewController();
PresentViewController(home, true, null);
Does it turn black because PresentViewController expects a XIB-file from the homeViewController? I want the user to stay in the storyboard, so he can continue by segueing through my application.
Does someone has an idea?
Thanks in advance.
Did you create the empty constructor yourself? If so, then its not loading the information from the storyboard, which is why it's black.
To create the controller call this:
var controller = Storyboard.InstantiateViewController("HomeViewController") as UIViewController;
You will also have to open the controller in XCode and set its "Storyboard ID" to "HomeViewController". This is the second tab from the left (I think) in the details pane. The same tab where you change the class.

Categories