I am trying to use Xamarin Forms pages in a Xamarin IOS Native app. To do that I am using the CreateViewController. The issue I am facing is that every time I push a new view controller, memory are allocated that are not released when I click on the back button. This results in that the app will crash. Is this the wrong way to do it?
var _historyViewController = new HistoryPage().CreateViewController();
// And push it onto the navigation stack
_navigation.PushViewController(_historyViewController, true);
Link to code: https://github.com/toupilsner/XamarinFormsEmbedded/blob/master/README.md
Related
First, please bear with me, I'm more of a Native dev on iOS side.
I've successfully made this "slim binding" by following this youtube video. The binding spits out UIView and Android View, which I can use on each Xamarin.iOS and Xamarin.Android app. As titled, the part that I can't figure out is how to use these bindings on XAML?
The closest thing I found is this: https://www.xamboy.com/2020/07/28/creating-a-binding-library-in-xamarin-part-2/ but that example pushes a whole view controller rather than just a simple view where I can have other things on top.
For context, the slim binding I made is for AWS IVS Player. Can't figure out any other way to have a player that has 2-3 secs of latency other than using their own player.
The project I'm working on was using Xamarin Forms (3.4.0.x) Cross Platform, so obviously the iOS app had the UIWebView built in.
We decided to migrate to WKWebView, which required the Xamarin Forms 4.4 update so we proceeded to do that then added [assembly: ExportRenderer(typeof(WebView), typeof(Xamarin.Forms.Platform.iOS.WkWebViewRenderer))] to the AssemblyInfo.cs in our iOS app, like it says to do here. https://github.com/xamarin/Xamarin.Forms/pull/3346
Now I think that's all I need to do completely migrate to WK, but I have noticed that the app has slowed down significantly, taking ~5x as long to load a page, and on top of that, this loading icon stays on the screen even after the page is done loading
My questions are:
Did I migrate correctly, or are there any steps I'm missing/did wrong? Has anyone run into this loading icon problem before? Please ask me to clarify if I'm leaving information out, I'm new to Xamarin Forms so I'm not sure how to ask the best questions, and this is a big project I'm being introduced to. I have been told there is no custom iOS WebView Renderer though, so everything is done using the default WebView.
Thanks!
It is a native iOS issue caused because of the time it takes to detect phone numbers on the web page. So if you just disable that detection, it should work better.
Here's a sample of how you can do it in Xamarin:
var urlRequest = new NSUrlRequest(new NSUrl("https://www.gooogle.com"));
var config = new WebKit.WKWebViewConfiguration();
config.DataDetectorTypes = WebKit.WKDataDetectorTypes.Address;
var frame = new CoreGraphics.CGRect();
var webView = new WebKit.WKWebView(frame, config);
webView.LoadRequest(urlRequest);
If you followed the link you shared, you should be able to put the code inside the SetElement function of the WkWebViewRenderer. So your code would look like this:
var config = new WebKit.WKWebViewConfiguration();
config.DataDetectorTypes = WebKit.WKDataDetectorTypes.Address;
WebView = new WebKit.WKWebView(WebView.Frame, config);
There's an easier solution that just went public from the Xamarin team. All you need to do is update the Forms Nuget, Visual Studio, and Xamarin.iOS, and then:
... go to your iOS project, open the project properties and add this flag in the additional mtouch arguments field: --optimize=experimental-xforms-product-type.
I am currently developing an App for IOS and Android with Xamarin Forms. I am debugging with my Android device.
Starting yesterday, when trying to build and test my solution, it falls into a break state before the App is even loaded.
The exception is:
System.InvalidProgramException: Method wuut.Discover:InitializeComponent () is too complex.
It works when I unplug my Android device and open the App on developer mode. But I really need the Console etc. so right now, I am unable to continue developing my app.
I looked up the exception on Google but couldn't really find anything similar to my problem.
The error occurs inside InitializeComponent on one of my Contentpages containing an AbsoluteLayout.
The AbsoluteLayout is rather big with 5400 Lines of Code. So looking into the error messages, I tried to remove a few chunks of my XAML and it started working again.
So my question is: Does XAML or Xamarin have some limitations on how big an AbsoluteLayout/Contentpage should be? If not, how would I resolve this issue?
Thanks in advance and kind regards
Xamarin.forms provides the ListView control. I followed the implementation of #jamesmotemagno for grouped list view. The application works fine. But the only problem is with sticky group header which comes default in ios and windows but not in android. This is very irritating just because of android I need to implement the custom rendering which led to render on ios and windows, which is not required. Is there any way to solve this problem of sticky header in android without disturbing ios and windows. Please suggest any solution for android.
I'm trying to follow this tutorial on creating a login page using Auth0: https://auth0.com/docs/quickstart/native/xamarin/01-login#handing-the-callback-url and noticed that the tutorial creates two separate login pages for android and iOS, as if they are two separate apps/projects/solutions. But my app is supposed to be compatible with both android and iOS, so I created a forms page under RoseySports.ios called Login_iOS (As indicated in screenshot 1) and would like to test it out to see if the login page works, but cannot seem to find a way to set the MainPage as Login_iOS (screenshot 2). I would like for it to be so that if a device is running iOS, it will redirect the user to the iOS version of the login page, and vice versa for android. Sorry if I'm not using the correct terminology when describing my issue. The reason I had to create two separate login pages for iOS and android was because i had to use using Auth0.OidcClient; as there are separate Nuget packages for the iOS solution and Android solution, which doesn't work when trying to put it on the main project (the one compatible for both iOS and Android).
And please let me know if there's a way to make just one login page for both platforms using Auth0.
UPDATE:
This is what I've done now, but I'm getting an error at MainPage = new RoseySports.Login_iOS(); saying that Login.iOS does not exist in the namespace RoseySports. This is the rest of the code:
`switch(Device.RuntimePlatform)
{
case Device.iOS:
MainPage = new RoseySports.Login_iOS();
break;
case Device.Android:
MainPage = new Login_Page();
break;
}`
You have multiple questions and in StackOverflow you should not ask them in one question, but let's try to address them:
Pages are only graphic elements and there is no need to implement separate graphic elements in iOS and Android in most cases, and yours doesn't look like a valid one for that
In general you can implement some code as platform specific. If you are using shared projects you can use conditional compiling, if not then dependency injection
You can use some of the technics above to do what you wanted to do (have different versions of pages per platform)