Skip to content

Instantly share code, notes, and snippets.

View Clancey's full-sized avatar

James Clancey Clancey

View GitHub Profile
public override void OnActivated (UIApplication application)
{
//When your app is backgrounded, iOS takes a snapshot.
//When the app comes back from the background it shows this snapshot at launch until your app is ready
//Sometimes apple forgets to remove the splash screen.
//Your app is in the forground and working. To prove it you can rotate, and see half your real screen.
//To prevent this from happening you can manually remove the view
foreach (var w in application.Windows) {
if (w != null && w != window) {
@Clancey
Clancey / gist:4e13c61adab63db4b219
Last active August 29, 2015 14:14
Insights Logger
public static void Log (Exception ex, ReportSeverity severity= ReportSeverity.Error,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
try{
Console.WriteLine (ex);
Console.WriteLine("{0} - {1} - {2} \r\n {3}",sourceFilePath,memberName,sourceLineNumber,ex);
NSInternalInconsistencyException Reason: Only RGBA or White color spaces are supported in this situation.
#if UNIFIEDAPI
using UIKit;
using CoreLocation;
using CoreGraphics;
#else
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.CoreLocation;
#endif
static List<AVAudioPlayer> players = new List<AVAudioPlayer>();
static async Task<bool> PlayAudioFile(string path)
{
var tcs = new TaskCompletionSource<bool> ();
var player = AVAudioPlayer.FromUrl (NSUrl.FromFilename (path));
players.Add (player);
player.FinishedPlaying += (object sender, AVStatusEventArgs e) => {
Console.WriteLine ("done");
tcs.TrySetResult(true);
};
public static class ButtonExtensions
{
public static Button OnTap(this Button button, Action tapped)
{
button.Clicked += (s, e) => tapped ();
return button;
}
}
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Praeclarum.UI
{
public abstract class StoryBoardRenderer<T> : UIViewController, IViewRenderer where T : UIViewController
{
string storyboardName;
string viewControllerStoryBoardId;
public StoryBoardRenderer (string storyboard, string viewControllerStoryBoardId = "")
{
this.viewControllerStoryBoardId = viewControllerStoryBoardId;
using System;
using NUnit.Framework;
using System.Threading.Tasks;
using System.Threading;
using NUnit.Framework.Constraints;
namespace gMusic
{
[TestFixture]
public class SignInTests
@Clancey
Clancey / simple action sheet
Last active December 30, 2015 05:29
I was tired of doing switch/case statements whenever I used a UIAction sheet. I also didn't like that I couldn't change the color of a specific button. So Simple Action Sheet was born.
/*
var options = new [] {
Priority.Low,
Priority.Normal,
Priority.High,
};
var sheet = new SimpleActionSheet {
Title = file.ToString()