Is this a bug in MonoTouch GC?

This is an unfortunate side-effect of MonoTouch (who is garbage collected) having to live in a reference counted world (ObjectiveC). There are a few pieces of information required to be able to understand what’s going on: For every managed object (derived from NSObject), there is a corresponding native object. For custom managed classes (derived from … Read more

How I can call a javascript function with MonoTouch and vice versa?

To invoke Javascript code running in the UIWebView from your application, use the EvaluateJavascript method, like this: myView.EvaluateJavaScript (“a = 1;”); To call back into your C# code, the only option is to hook up to the ShouldStartLoad property like this: myView.ShouldStartLoad = myHandler; […] bool myHandler (UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navType) { // … Read more

Write device platform specific code in Xamarin.Forms

This is a scenario which is easily resolved with dependency injection. Have a interface with the desired methods on your shared or PCL code, like: public interface IUserPreferences { void SetString(string key, string value); string GetString(string key); } Have a property on your App class of that interface: public class App { public static IUserPreferences … Read more

Receiving Push Notifications while in background

application:didReceiveRemoteNotification: will call in the background only when you have added content-available key with value 1 into the notification payload. In case of the Urban Airship, you can send Test Push under the Setting tab. Sample Payload for Push Notifications: { “aps”: { “alert”: “aaaa”, “badge”: “+1”, “content-available”: “1” }, “device_tokens”: [ “86BA71E361B849E8312A7B943BA6B26A74AB436381CF3FEE3CD9EB436A12A292” ] } … Read more

Is MonoTouch now banned on the iPhone? [closed]

Update – This changed recently. MonoTouch should no longer conflict with the agreement. Any statements below are purely historical! Yes, it seems pretty clear from their license agreement now that if the original application is written in C# then it would be violating the license: …Applications must be originally written in Objective-C, C, C++, or … Read more

Hamburger Menu Xamarin Forms (MasterDetailPage)

Creating the master-detail page: Add a content page and change the code as follows : RootPage.xaml <?xml version=”1.0″ encoding=”utf-8″?> <MasterDetailPage xmlns=”http://xamarin.com/schemas/2014/forms” xmlns:x=”http://schemas.microsoft.com/winfx/2009/xaml” xmlns:local=”clr-namespace: your_NameSpace” x:Class=”your_NameSpace.RootPage”> </MasterDetailPage> RootPage.xaml.cs [XamlCompilation(XamlCompilationOptions.Compile)] public partial class RootPage : MasterDetailPage { public RootPage() { InitializeComponent(); } } Creating its Menu Page: Add another content page and change the code as follows … Read more

How to force a UIViewController to Portrait orientation in iOS 6

If you want all of our navigation controllers to respect the top view controller you can use a category so you don’t have to go through and change a bunch of class names. @implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } – (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers … Read more