Skip to content

Instantly share code, notes, and snippets.

@ajonno
ajonno / customsegue.txt
Last active July 3, 2016 04:15
Custom Segue (left-right ; right-left)
//create a custom segue on storyboard between two ***UIViewControllers*** (ie. this example doesn’t need a navigation controller)
//use the class below as the custom segue class.
//use your own identifier eg. “customSegue”)
class CustomSegue: UIStoryboardSegue {
override func perform() {
let src = self.sourceViewController
@ajonno
ajonno / repository-pattern-swift.txt
Created June 24, 2016 06:21
Example of Repository pattern using Swift
// credit -> http://acqui-hire.me/dependency-injection-with-the-cake-pattern-in-swift/
public struct User {
public let username: String
public let password: String
}
public protocol UserRepository {
func findByUsername(username: String) -> User?
}
@ajonno
ajonno / Release Designer Assets Outlets.txt
Created December 18, 2015 01:02
Release Designer Assets/Outlets - Xamarin
public override void ViewDidUnload ()
{
 base.ViewDidUnload ();
 
 // Clear any references to subviews of the main view in order to
 // allow the Garbage Collector to collect them sooner.
 //
 // e.g. myOutlet.Dispose (); myOutlet = null;
 
 ReleaseDesignerOutlets ();
}


@ajonno
ajonno / customsegueanimation.txt
Created June 28, 2015 01:42
Custom segue animation DONE RIGHT (no post render flashing)
class InitialLBPSegue: UIStoryboardSegue {
override func perform() {
var firstVCView = sourceViewController.view as UIView!
var thirdVCView = destinationViewController.view as UIView!
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(thirdVCView, belowSubview: firstVCView)
thirdVCView.transform = CGAffineTransformScale(thirdVCView.transform, 0.001, 0.001)
@ajonno
ajonno / gist:0f988d8f08616fbfc4b1
Last active August 29, 2015 14:16
Create circle using Core Graphics
public class CircleView : UIView
{
private UIColor color;
public CircleView (UIColor color)
{
this.color = color;
}
public override void Draw (CGRect rect)
@ajonno
ajonno / gist:6ae0d2aebfae79d2ec9c
Created June 27, 2014 03:53
how to "reset" a selected row in a ListView --->> when using Xamarin.Forms
listView.ItemSelected += async (object sender, SelectedItemChangedEventArgs e) => {
//Paste this ---v
// Prevents .ItemSelected from running again when SelectedItem is set to null on line below
if (listView.SelectedItem == null)
return;
// Sets the SelectedItem so it can be used by the Switch statement below
var whichCategory = (Category)e.SelectedItem;
@ajonno
ajonno / gist:bb081a1c2239d357e0ac
Last active August 29, 2015 14:02
Xamarin - basic map creation + current location + set a pin + zoom level
// put a map into the View
var map = new MKMapView (UIScreen.MainScreen.Bounds);
View = map;
//allows user location to be shown on a map
map.ShowsUserLocation = true;
//get my current geo-location lat/long coordinates
var myCoord = map.UserLocation.Coordinate;
Console.WriteLine ("lat {0}, long {1}", myCoord.Latitude, myCoord.Longitude);