Skip to content

Instantly share code, notes, and snippets.

#if MONOTOUCH
[DllImport("sqlite3", EntryPoint = "sqlite3_open")]
public static extern Result Open(string filename, out IntPtr db);
...
...
...
#else
@anujb
anujb / gist:1177040
Created August 28, 2011 18:52
wepopover binding commands
btouch command:
/Developer/MonoTouch/usr/bin/btouch WEPopoverController.cs WEPopoverContainerView.cs WEPopoverParentView.cs WETouchableView.cs --outdir=gen -ns=WEPopover --unsafe --sourceonly=genfiles
smcs command:
/Developer/MonoTouch/usr/bin/smcs -out:WEPopover.dll `cat genfiles` -unsafe -r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll -target:library
mtouch arguments:
@anujb
anujb / gist:1179097
Created August 29, 2011 18:49
WEPopover Invalid Selector
2011-08-29 13:56:48.278 WEPopoverSample[11426:1207] -[WEPopoverController presentPopoverFromRect:]: unrecognized selector sent to instance 0x7546030
Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[WEPopoverController presentPopoverFromRect:]: unrecognized selector sent to instance 0x7546030
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_RectangleF_IntPtr_UInt32_bool (intptr,intptr,System.Drawing.RectangleF,intptr,uint,bool)
at WEPopover.WEPopoverController.PresentFromRect (RectangleF rect, MonoTouch.UIKit.UIView view, UIPopoverArrowDirection direction, Boolean animated) [0x00000] in <filename unknown>:0
at WEPopover.Sample.AppDelegate.<HandleButtonTouchDown>m__0 () [0x0001a] in /Users/abhatia/projects/monotouch/github/monotouch-bindings/WEPopover/WEPopover.Sample/Main.cs:52
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. N
@anujb
anujb / gist:1196024
Created September 5, 2011 22:02
MapWithRouteViewController
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
_MapView = new MapView(new RectangleF(0, 0, View.Frame.Width, View.Frame.Height));
_MapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
View.AddSubview(_MapView);
@anujb
anujb / gist:1229631
Created September 20, 2011 16:49
universal build script
xcodebuild -sdk iphonesimulator -target WEPopover -configuration ${CONFIGURATION} BUILD_DIR=${BUILD_DIR} CONFIGURATION_TEMP_DIR=${CONFIGURATION_TEMP_DIR}
xcodebuild -sdk iphoneos -target WEPopover -configuration ${CONFIGURATION} BUILD_DIR=${BUILD_DIR} CONFIGURATION_TEMP_DIR=${CONFIGURATION_TEMP_DIR}
mkdir -p "${BUILD_DIR}/${CONFIGURATION}-universal"
lipo \
"${BUILD_DIR}/${CONFIGURATION}-iphoneos/libWEPopover.a" \
"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/libWEPopover.a" \
-create -output "${BUILD_DIR}/${CONFIGURATION}-universal/libWEPopover.a"
@anujb
anujb / gist:1229551
Created September 20, 2011 16:16
otool -tv libWEPopover.a | grep ^.......2
00000002 af03 add r7, sp, #12
00000012 6166 str r6, [r4, #20]
00000022 9215 str r2, [sp, #84]
00000032 9212 str r2, [sp, #72]
00000042 9916 ldr r1, [sp, #88]
00000052 910d str r1, [sp, #52]
00000062 4a55 ldr r2, [pc, #340] (0x1b8)
00000072 447a add r2, pc
00000082 689c ldr r4, [r3, #8]
00000092 6ec8 ldr r0, [r1, #108]
public class TreatmentViewController : DialogViewController
{
public TreatmentViewController()
: base(UITableViewStyle.Plain, new RootElement(""))
{
}
public override void ViewDidLoad()
{
Root.Add(new Section("A")
@anujb
anujb / gist:1258212
Created October 3, 2011 00:56
UIAppearanceExtensions
public static class UIAppearanceExtensions
{
public static T Appearance<T>(this T obj) where T : NSObject
{
return UIAppearance.FromObject(obj) as T;
}
}
@anujb
anujb / gist:1294537
Created October 18, 2011 03:22
hide browser action example
using System.Collections.Generic;
namespace SozoChildrenInternational
{
public partial class FirstViewController : UIViewController
{
Action HideBrowserAction;
public FirstViewController () : base ("FirstViewController", null)
{
@anujb
anujb / gist:1319930
Created October 27, 2011 15:43
responder chain psueudocode -- untested
public T GetContainerOfType<T>(UIView view) where T : UIViewController
{
var type = typeof(T);
var nextResponder = view.NextResponder;
if(typeof(nextResponder) == type) {
return nextResponder;
}
else if(typeof(nextResponder) == typeof(UIView)) {