Using GlassButtons programmaticaly
Found some excellent code to create glassbuttons using the undocumented UIGlassButton class. Trying for hours to port the ObjC code until i found: http://monotouch.pastebin.com/H4cnuKpG.
Class theClass = new Class("UIGlassButton");
IntPtr o = Messaging.intptr_objc_msgSend (theClass.Handle, Selector.GetHandle ("alloc"));
var frame = new RectangleF(10, 10, 120, 44);
UIButton b = (UIButton) Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend_RectangleF (o, Selector.GetHandle ("initWithFrame:"), frame));
b.BackgroundColor = UIColor.FromHSBA(0.267f, 1.000f,0.667f,1.000f);
this.View.AddSubview(b);
Adding iAds to MonoTouch
Playing aroung with the all brand new MonoTouch and the iOS 4 SDK, i decided it was time to create some adds.
The following snippet will create an UIView you can use within your app to get you started.
The code below is a slightly modified version found on: http://monotouch.info/iAD-with-Monotouch and all credit should go to Manniat
public UIView CreateAdBannerView() {
ADBannerView adBannerView = new ADBannerView ();
NSMutableSet nsM = new NSMutableSet ();
nsM.Add (new NSString ("ADBannerContentSize320x50"));
adBannerView.RequiredContentSizeIdentifiers = nsM;
adBannerView.AdLoaded += delegate(object sender, EventArgs e) {
((ADBannerView)sender).Hidden = false;
};
adBannerView.FailedToReceiveAd += delegate(object sender, AdErrorEventArgs e) {
((ADBannerView)sender).Hidden = true;
};
adBannerView.Frame = new RectangleF (0, 9, 320, 50);
adBannerView.Hidden = true;
return adBannerView;
}
Embedding video on the iPhone using HTML5
I just discovered the iPhone OS 2.0 already supports some great HTML5 features including the embedding of mp4 video content. Embedding video content on the iPhone is now a real breeze, compared to the good old embed and object tags.
To embed your video using either the UIWebView or native html page, you can now use the following.
for a excellent cross-browser implementation, check out: http://camendesign.com/code/video_for_everybody#video-code
OSX: Into the grey yonder…
Like most technocrats, i've tried out an huge amount of OS systems during my both personal and professional career. My latest addon to this list is Snow Leopard, and i have to say there is much controversy as i both love and hate it at the same time. Finding some spare time, i found it necessary to finally express my own findings on OSX, and what i do and dont like about it. I know there are quite some Apple fanboys who would love to pick a fight without a proper argument and i always notice their technical skills are nothing more than being able to launch Photoshop.
This article should bring a more weighted review when thinking of buying a Mac, rather than reading through a lot of fanboy reviews.
Boot time
[+] Booting OSX is without a doubt a very optimized system, that shows its speed during the load of the OS. Apple has made a tremendous effort to organize the way background services and libraries are loaded and even on the slower MacBook Air (1.8Ghz) it boots nicely. Without doing proper boot measurements, i can truly say it beats both Ubuntu and Windows 7.
Look and feel
[-] In 2001 OSX looked the bees-knees, but now-adays the greyish looks feel outdated compared to full coloured OS'es. No theming/skinning in the OS allowed... Thats kinda crap fro a system targetted at designers.
[+] Cool new dockmenu options to view docked folderitems as stacks, grid or list.
[+] Very easy to add and remove items from the dockmenu. (Way easier than managing a Windows StartMenu).
[-/+] Having multiple desktops is a blessing for those working on multiple applications, however on a Mac it seems more like a must since application windows are a constant clutter.

OSX Finder
Apple has always tried its Mac as beeing as userfriendly as it should be, however i think users should be more empowered than the current implementation of Finder allows us.
[-] No exit-application Icon on the top window-bar... Yess, this has been a topic for most warfares, but come on... Whats the point of an exit button if it only closes the current window and you need to shortkey or the menu to properly close the application.. This is seriously silly. If i wanted to hide my window, i would only need a hide button. Since UI design is al about usability, i would like to see a proper exit button, and the close-window functionality moved to the menu-bar (is this really that terrible?).
[-] Unable to extend the context-menu (right-click mouse) in order to: Create new filetypes (Windows) or expand functionality yourself like KDE and Gnome on Linux.
[-] Finder File menu, misses some important features; namely Move files... Files can only be moved using drag-and-drop, or the Terminal.
[-] Finder window doesnt have a changeble path bar. When navigating through folders your either stick to the click actions, or type the adress yourself using Go->Go to Folder.
[+] Preview; Using the space bar, you can quickly look into the contents of a PDF, single-image or start a slideshow. Quiete impressive and more importantly... very very fast.
[+] Smart Folders: Like Gmails filter; An very cewl feature to create a folder that has an dynamic view of the indexed files, based on your criteria. Nice!!!

Software installation
[+] Application packages in MacOS is an excellent example how an OS should contain applications, in there own damn space. Unfortunately Apple software does leave minor traces in other directories such as the ~Library folder.
Misc
[-] Defragmentation... i hear you argue, that the Apple File System wouldnt need defragmentation, well i beg the differ. I installed iDefrag and run some tests, after months and months of usage. The verdict is; if you want to keep a clean, fast booting harddrive.. Just run defrag. Only too bad Apple didnt stick in a proper defrag tool themselves.
[-] Objective-C: What a truly horrible language to work with.. Go learn C++; Its better faster and easier to read/maintain. Fortunately.. You can stick your C++ code straight in your Cocoa app, but still you need some ObjC plumbing.
[-/+] Safari: If Steve calls Flash "a memory hog", he should considering firing the people who've built Safari .. Dont get me wrong.. Its a good browser. But less advanced and more heavy (137mb at time of writing) than both Firefox and Google Chrome combined.
[-/+] Itunes: If Steve calls Flash "a memory hog", he should considering firing the people who've built iTunes. Great Application.. To bad you cant sync multiple libraries without any hacks. Maintaining lists from a NAS is terrible, and organizing a dedicated Music folder will create ANOTHER Music-Folder and move the files... Only why too get rid of those annoyances: TURN OFF These Features.
[+] Time Machine; Backing up content using Time Machine is realy awesome and trouble free. However, everyone should Install and use "Time Machine Editor" in order to take control of your backups, and create your own backup schedule. A scheduler for Time Machine should have come with the system, as its backups are always part of maintenance cron-jobs.
[+] Apache with PHP and other modules pre-installed.
[+] Runs X11 apps and the whole POSIX set of utilities.
[+] Excellent ActivityMonitors, Logfile-readers.. and ofcourse our belove 'ps' command.
Conclusion
OSX is an awesome OS as a whole, but when working on the system itself rather than just opening applications, you will find a lot of shortcomings. Finder is definitely not the best navigation based file organizer, and after all those updates you would guess that Steve did something to improve his beloved OS instead of spending all the budget on an electronic book reader. There are however quite some good Finder alternatives out there, that can be installed and used instead. See http://www.simplehelp.net/2006/10/08/10-os-x-finder-alternatives-compared-and-reviewed/ for an overview of good Finder alternatives. For the rest of the OS, it still does deliver some eye-candy and innovative functionality thats making it all worthwhile. Since running OSX i have less Linux cravings thanks to this FreeBSD-like OS.
Updating the splash screen by capturing the current app screen on exit
Hi everyone,
This little method saves the current screen of the application on exit, and use it as splashscreen when the application is started back up again.
Apple endorses to create a snapshot of the application and use it as splashscreen (so the UI gives feedback while initializing the application), but to give a nicer touch to the process i decided to code this programmatically.
Enjoy!
public override void WillTerminate (UIApplication application)
{
// Save screenshot as splashscreen
UIGraphics.BeginImageContext (window.Bounds.Size);
window.Layer.RenderInContext (UIGraphics.GetCurrentContext ());
UIImage image = UIGraphics.GetImageFromCurrentImageContext ();
UIGraphics.EndImageContext ();
NSError err = new NSError ();
image.AsPNG ().Save ("Default.png", true, out err);
}
Custom UIAlertView with Progressbar or ActivityIndicator
Download CAlertView.zip
Today i was playing around creating a some custom loading indicators using the UIAlertView control. After beeing quiete unsatisfied with the content found on the web, i decided to rollup my own custom control in order to simplify the implementation. This implementation makes use of the this.InvokeOnMainThread function, so the UIView is redrawn properly.


CAlertView.cs
using System;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace Controls
{
public enum CAlertViewType { ProgressBar, ActivityIndicator };
[MonoTouch.Foundation.Register("CAlertView")]
public class CAlertView : UIAlertView
{
public CAlertViewType AlertViewType { get; set; }
public UIProgressView ProgressView { get; set; }
public UIActivityIndicatorView ActivityIndicator { get; set; }
public CAlertView (IntPtr handle) : base(handle)
{
}
[Export("CAlertView:")]
public CAlertView (NSCoder coder) : base(coder)
{
}
public CAlertView ()
{
}
private bool setUpComplete = false;
public override void Draw (RectangleF rect)
{
if (setUpComplete==false) {
switch (this.AlertViewType) {
case CAlertViewType.ProgressBar:
if (this.ProgressView==null) {
this.ProgressView = new UIProgressView();
ProgressView.Style = UIProgressViewStyle.Default;
ProgressView.Progress = 0f;
}
this.ProgressView.Frame = new RectangleF(30.0f, rect.Height - 50f, 225.0f, 11f);
this.AddSubview(this.ProgressView);
break;
case CAlertViewType.ActivityIndicator:
if (this.ActivityIndicator==null) {
this.ActivityIndicator = new UIActivityIndicatorView();
this.ActivityIndicator.Frame = new RectangleF(139.0f-18.0f, rect.Height - 63f, 37.0f, 37.0f);
}
this.AddSubview(this.ActivityIndicator);
this.ActivityIndicator.StartAnimating();
break;
}
setUpComplete=true;
}
base.Draw (rect);
}
private void UpdateProgressBar() {
this.ProgressView.SetNeedsDisplay();
this.SetNeedsDisplay();
}
///
/// Updates the layout using the mainThread
///
public void Update() {
if (this.ProgressView!=null) {
this.InvokeOnMainThread(UpdateProgressBar);
}
}
public void Hide(bool animated) {
this.DismissWithClickedButtonIndex(0,animated);
}
}
}
To use it: here is an example of the AppDelegate.cs using a sleepy thread to simulate content loading.
Main.cs
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using System.Drawing;
using System.Threading;
namespace LoadingScreen
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args);
}
}
// The name AppDelegate is referenced in the MainWindow.xib file.
public partial class AppDelegate : UIApplicationDelegate
{
Controls.CAlertView alertView = new Controls.CAlertView();
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window.Add(alertView);
window.MakeKeyAndVisible ();
alertView.Message ="Loading Content...";
alertView.AlertViewType = Controls.CAlertViewType.ProgressBar;
alertView.Show();
ThreadStart tsWorker = new ThreadStart(workerThread);
new Thread(tsWorker).Start();
return true;
}
public void workerThread() {
alertView.Update();
Thread.Sleep(500);
alertView.ProgressView.Progress += 0.1f;
if (alertView.ProgressView.Progress<1.0f) {
workerThread();
} else {
this.alertView.Hide(false);
this.alertView.RemoveFromSuperview();
}
}
// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
}
}
OSX86 – (Re) installing X11
After removing X11 to save some much required space on my netbook, i noticed MonoTouch was unable to install as it has some rooted dependencies from X11 (might be caused by GTK#). So i was back to my iATKOS, iDeneb installation discs to find out the necessary Extra Options.pkg is nowhere to be found. Thankfully the packages are freely distrobuted available (someting i didnt expect even though X11 is completely open-licensend. You can find and download all X11 packages on the macosforge website: http://xquartz.macosforge.org/trac/wiki/Releases
happy (re) installing X11
OSX86 – Sapphire Radeon HD 3850
Today i finally gave up, enabling QE for my AGP card. The card is running in full HD resolution (1920x1080) so i am pleased enough to start the iPhone Development of Crossfire Media Player.
Crossfire Support forum temporary closed
Since i received tons of SPAM on the forum the last couple of weeks, i've decided to close it down until phpBB supports better capchapta validation and message control. On the other side, i am going to search for alternatives.