Skip to content

Instantly share code, notes, and snippets.

@anujb
anujb / gist:1474324
Created December 13, 2011 22:53
QElement selected
- (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller indexPath:(NSIndexPath *)indexPath {
[[tableView cellForRowAtIndexPath:indexPath] becomeFirstResponder];
if (_onSelected!= nil)
_onSelected();
if (self.controllerAction!=NULL){
SEL selector = NSSelectorFromString(self.controllerAction);
if ([tableView.controller respondsToSelector:selector]) {
objc_msgSend(tableView.controller ,selector, self);
@anujb
anujb / gist:1453770
Created December 9, 2011 23:16
MonoTouch Generic UIGestureRecognizer
namespace FireHouse.UI.iOS
{
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.ObjCRuntime;
public class Recognizer<T> : NSObject where T : UIGestureRecognizer, new()
{
T fRecognizer;
@anujb
anujb / gist:1337013
Created November 3, 2011 16:43
youtube js seek ahead by percentage
function(percent) {
var time = percent * player.getDuration();
player.seekTo(time, true);
}
@anujb
anujb / gist:1331845
Created November 1, 2011 20:44
Custom Container Transition Workflow
public class MyContainerViewController : UIViewController {
public MyContainerViewController()
: base() {
}
public void Handle_Button1_Clicked(object sender, EventArgs e) {
// ..Initialize myFirstChildViewController
// and mySecondChildViewController here.
this.Transition(myFirstChildViewController, mySecondChildViewController, 1.5,
@anujb
anujb / gist:1331744
Created November 1, 2011 20:05
Adding Child ViewController Workflow
myChildViewController = new MyChildViewController();
this.AddChildViewController(myChildViewController);
this.View.AddSubView(myChildViewController.View);
@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)) {
@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: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;
}
}
public class TreatmentViewController : DialogViewController
{
public TreatmentViewController()
: base(UITableViewStyle.Plain, new RootElement(""))
{
}
public override void ViewDidLoad()
{
Root.Add(new Section("A")
@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"