Skip to content

Instantly share code, notes, and snippets.

View dbeattie71's full-sized avatar

Derek Beattie dbeattie71

  • Nebraska
  • 06:22 (UTC -05:00)
View GitHub Profile
if (KeyboardType == UIKeyboardType.NumberPad)
{
NSNotificationCenter.DefaultCenter.AddObserver (
"UIKeyboardDidShowNotification", (notification) => {
UIButton doneButton = new UIButton(new RectangleF(0, 163, 106, 53)); //{ButtonType = UIButtonType.Custom};
//doneButton.SetTitle("Done", UIControlState.Normal);
doneButton.SetImage(UIImage.FromFile("DoneUp.png"), UIControlState.Normal);
doneButton.SetImage(UIImage.FromFile("DoneDown.png"), UIControlState.Highlighted);
doneButton.AdjustsImageWhenHighlighted = false;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
namespace SignalR.Client.MonoTouch.Sample
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public static void DismissKeyboard(UIView view)
{
if (AppManager.IsKeyboardVisible)
{
var text = new UITextField(RectangleF.Empty);
view.AddSubview(text);
text.BecomeFirstResponder();
text.ResignFirstResponder();
text.RemoveFromSuperview();
text.Dispose();
@dbeattie71
dbeattie71 / gist:2baf841b2aec86c2a16f
Last active August 29, 2015 14:15
HijackTest crash
2015-02-16 14:24:38.950 HiJackTest[4944:2813532] Attempting to JIT compile method '(wrapper managed-to-native) System.Func`3<intptr, intptr, intptr>:wrapper_aot_native (intptr&,intptr,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
2015-02-16 14:24:39.002 HiJackTest[4944:2813532] Moving to: <UIStatusBar: 0x154854a00; frame = (0 0; 0 20); opaque = NO; layer = <CALayer: 0x17003e4c0>>
2015-02-16 14:24:44.716 HiJackTest[4944:2813532] Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
at HiJackTest.Application.MyCapture (IntPtr block, IntPtr self, IntPtr uiView) [0x00018] in /Users/dbeattie/HijackTest/HiJackTest/Main.cs:54
at (wrapper native-to-managed) HiJackTest.Application:MyCapture (intptr,intptr,intptr)
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr
@dbeattie71
dbeattie71 / gist:5dc4b86085b962111321
Created February 17, 2015 20:03
How to port “method_getImplementation” and “method_setImplementation” to MonoTouch?
[DllImport("/usr/lib/libobjc.dylib")]
extern static IntPtr class_getInstanceMethod(IntPtr classHandle, IntPtr Selector);
[DllImport("/usr/lib/libobjc.dylib")]
extern static IntPtr method_getImplementation(IntPtr method);
[DllImport("/usr/lib/libobjc.dylib")]
extern static IntPtr imp_implementationWithBlock(ref BlockLiteral block);
[DllImport("/usr/lib/libobjc.dylib")]
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="@+id/card_view_friend"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
card_view:cardUseCompatPadding="true">
Snippet Name: iOS Utils
Platform: Xamarin.iOS
Function: Check if running iOS 8, is phone, is tall, and envoke on UI Thread
Snippet:
public static class Utils
{
public static NSObject Invoker;
public class CustomFragmentsPresenter : MvxFragmentsPresenter
{
public interface IMvxFragmentHostEx : IMvxFragmentHost
{
void Close(IMvxViewModel viewModel);
void ChangePresentation (MvxPresentationHint hint);
}
private IMvxNavigationSerializer _serializer;
/*
Snippet Name: InlineTableViewSource
Platform: iOS
Function: A subclass of UITableViewSource that allows you to define UITableViewDataSource and UITableViewDelegate methods inline, rather than subclassing. Lets you take advantage of closures and use tableviews where you can't create subclasses, like in Xamarin Sketches (compile and reference).
Funcs/Actions are prefixed with "_", feel free to alter if this disagrees with your styling guidelines.
Usage:
var cellId = new NSString("cell");
public class TableViewController : UITableViewController
{
static readonly NSString CellId = new NSString ("C");
readonly TableViewSource source = new TableViewSource ();
readonly List<string> rows = new List<string> ();
public override void ViewDidLoad ()
{
base.ViewDidLoad ();