-
Book Overview & Buying
-
Table Of Contents
iOS Development with Xamarin Cookbook
By :
iOS is very strict about memory usage. If an app uses too much memory, iOS will issue memory warnings. If we do not respond to these memory warnings accordingly by releasing resources that are not needed, it is very likely that iOS will terminate the app.
Let's see what we can do to avoid this situation. Create a new project in Xamarin Studio and name it EfficientControllerApp.
Perform the following steps to complete this recipe:
Add a view controller to the project and name it MainController.
Enter the following code in the DidReceiveMemoryWarning method of the MainController class:
Console.WriteLine("Main controller received memory warning!");Make the controller the root view controller of the app in AppDelegate.cs as follows:
MainController mainController = new MainController(); window.RootViewController = mainController;
Compile and run the app on the simulator.
With iOS Simulator window active, navigate to Hardware | Simulate Memory...
Change the font size
Change margin width
Change background colour