Posts

Showing posts with the label Xamarin

UWP WebView Intermittently Fails to Load in a Xamarin.Forms App - Resolved!

As I've previously mentioned I've been porting an existing Xamarin.Forms app over to UWP and tonight I've had to tackle an annoying bug which was quite difficult to overcome and I thought worthwhile sharing. The bug occurs when loading WebViews with HTML directly rather than a URL. I found that roughly 1 in 5 page loads ended up a blank page being rendered. As this is now the third platform for the App I was fairly confident the html and everything was correct. First of all I suspected a layout issue and maybe the width/height was being messed up so I added a background colour to the control but this always rendered. So not a layout issue. A quick Google led me to Johan Karlsson's post on events needing to be added on the main UI Thread  this seemed better at first but i ended up still hitting the issue 1 in 10 page loads.  More googling led me to a Xamarin bug with the issue  but no resolution :( Taylor Buchanan comments on the bug with a work around howeve...

Auto Collapsing Master Panel inside Xamarin.Forms UWP app.

Recently I've been migrating a Xamarin.Forms application which works on phones and tablets over to UWP so that its compatible with Windows 10 and available on the desktop. Most things have ported well and after a few tweaks most things are running. However during testing I noticed something odd. I use a master detail page to provide a navigation pane and then a details pane. On phones the navigation page is shown and hidden as expected. On tablets if landscape the menu is always open and if portrait it pops up over the details. Now on UWP it behaves as the tablet however I also expected if the window became small or docked to the side of the screen the menu would again turn into a pop over, but Xamarin.Forms doesn't support this by default. It is however quite easy to support this via a custom renderer. We can override the elements size changed and determine the size of the element. If the size is less than the minimum we want the menu to be automatically opened for we can ...

Xamarin iOS for Simulator and Screenshots

Image
I love the Xamarin iOS Simulator for Windows , much easier than VNC'n to my Mac or having to constantly use my iPhone when I'm only playing around with UI and stuff. It has all the features you'd expect like show/hide keyboard, home button, rotate, trigger call etc. It also has capture screenshot which would be super handy. Tonight I needed to take a few screenshots so got trigger happy with the screenshot button but.... I couldn't find where they went! To cut a long story short I ended up using Process Monitor to find where the files were being written and it turns out they go to a Xamarin\iOS Simulator folder within your pictures folder. I never use mine on my development machine so didn't even consider checking there. So two tip Pro Tips: Xamarin iOS Simulator for Windows Screenshots goto: C:\Users\{username}\Xamarin\iOS Simulator Not sure where files are or whats using them... Don't forget about Process Monitor

The importance of all-age user testing and the UIButton Touch Area

Image
Of late I have been getting various users to try out an iOS app I have been building using Xamarin.iOS, and I got some interesting feedback which I thought I'd share. The app runs on iPod Touch's / iPhone's so a common platform. One of the areas people commented on was Ease of Use. Interestingly most people commented that the app felt natural and looked easy to use, however about 30% of my responses contained "I struggled to accurately tap the response icons", "I kept missing the buttons and began to get frustrated", "Wearing gloves seemed to make it harder to tap the icons". My first response to this was "really?", The icons by my standards were fairly large and didn't look too small, in fact I deliberately made them slightly larger than Apple's recommended 44x44 [ref: http://stackoverflow.com/questions/1928991/minimum-sensible-button-size-on-iphone ] So I found out more information from the affected users. Turns out ...

Base64 Images with Xamarin.IOS

Today I was adding the ability to render Base64 encoded image strings to my iOS application which is built using Xamarin.iOS. These images are just small thumbnails and are stored in a small database within my app. Since iOS 7 it's really easy to render these as UIImage's inside an UIImageView, in objective-c you simply do something along the lines of: NSData* data = [[NSData alloc] initWithBase64EncodedString:base64String options:0]; UIImage* image = [UIImage imageWithData:data]; With Xamarin.IOS this would translate to: var image = new NSData(base64image, NSDataBase64DecodingOptions.None); var uiImage = UIImage.LoadFromData(image); However running this gives you the following exception: System.Exception: Could not initialize an instance of the type 'MonoTouch.Foundation.NSData': the native 'initWithBase64EncodedData:options:' method returned nil. Ouch As this exception is within the NSData class which is a class that Xamarin generates to map...