Articles

Page 5



  • Basics of the NSNotificationCenter

    πŸ•‘2 minute read
    September 17, 2011

    The uses of NSNotificationCenter can be many; It is handy for using to notify the app that a background download of data, a post of some kind is done, or some calculation is finished. It can also be useful for letting sub views know when some root level functions happen in the app such as shutdown/sending to background because the user tapped the home button. In this example I will be doing just that.

    In the AppDelegate you should find a method named:

    - (void)applicationDidEnterBackground:(UIApplication *)application...

  • Preventing unstyled content before jQuery loads

    πŸ•‘2 minute read
    February 18, 2011

    jQuery is a very powerful tool but because of it's size it can be quite slow to load, and on some older devices it can also be slow to "boot up" and become ready for action (I'm looking at you iPad/iPhone!)

    Why is this a problem?

    In my case the problem is that jQuery loads after the main page body and then executes. This takes time. One of the actions the jQuery needs to do is to hide() an element, however before the jQuery is ready the element is visible. This means that when jQuery is finally ready there ...


  • Text Selection Color

    πŸ•‘1 minute read
    February 1, 2011

    A lesser know property of CSS3 is the selection property. This allows you to change the properties of text when selected so you can highlight it in any way you want

    /* Webkit */ ::selection { background: #000; } /* Firefox */ ::-moz-selection { background: #000; } 

    This sentence should highlight in black. And this in red.

    Don't forget that some browsers won't show this as it's CSS3


  • Turn off Chrome's textarea resizing

    πŸ•‘2 minute read
    January 24, 2011

    When building forms for websites, much time can be spent making sure that all the elements fit together in a nice way, all lining up and looking neat. So then along came Google's Chrome browser and with it came the ability to drag resize a text area to any size possible. Great. Great?

    While the ability to resize the text are to be the right size for the content being entered is a great feature, the need to do it on a well designed and styled site may make everything mess up. A well designed form should anticipate...


  • Forcing iOS phone numbers to link on a webpage

    πŸ•‘1 minute read
    December 14, 2010

    If you ever wondered how to remove the auto phone number conversion on web pages then look no further. Just place this in the head of your document and all should be OK.

    <head> ... <meta name="format-detection" content="telephone=no" /> Of course you may want to force pages to link a number. You can do this using: ... </head> <body> ... <a href="tel:+1-123-3456-7890"> Call my fake number on: 123-3456-7890 </a> Of course if you are browsing other peoples sites on your i/Pad/Phone...

  • Django Apps on MediaTemple and main.fcgi error

    πŸ•‘1 minute read
    November 11, 2010

    I was having had an issue with Django on my MediaTemple hosting and the urls being affected by a certain main.fcgi. It happened a while back, and then again recently so I decided to share the solution I found.

    Simply add the following to your settings.py file. Then restart the app and you should be good to go.

    FORCE_SCRIPT_NAME = '' 

  • ie6 double float margin bug

    πŸ•‘1 minute read
    August 8, 2010

    Here is the quickest fix I have found for fixing the ie6 double float margin bug, where all margin values are doubled on floating elements.

    Just apply:

    .element { display: inline; } 

    And the element float will be rendered as expected. Go figure...Thanks to http://www.positioniseverything.net/explorer/doubled-margin.html for shining a light on, and fixing this issue.


  • ie 7 min-width and button bug

    πŸ•‘1 minute read
    July 7, 2010

    A bug for anyone needing ie7 compatible forms using a min-width on the buttons. This also affects ie8 running in compatibility mode.

    input.submitbutton{ min-width: 100px;} 

    If you are using a min-width for your form submit buttons then sadly ie7 will align button text to the right of the button. It is un-fixable with just css and the only pure solution is to remove the min-width and either use width:auto; or use width:123px;

    input.submitbutton{ width: 100px;} 

    If however you don’t mind using JavaScript you ...


  • Accelerometer setup and usage

    πŸ•‘1 minute read
    May 5, 2009

    To use the accelerometer in an iPhone application you need to add the<UIAccelerometerDelegate> into the.h file of your application:

    @interface ApplicationViewController : UIViewController { ... } 

    Then in your .m file you must setup the accelerometer:

    - (void)viewDidLoad { UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer]; accel.delegate = self; accel.updateInterval = 1/30; } Update interval is in seconds so 1/30 is a 30th of a second. Now the accelerometer is setup you can use it: -(void)...

  • Creating and using an Array of objects in Objective-C

    πŸ•‘1 minute read
    April 4, 2009

    First we need an array to hold the objects (in this case bullets)

    NSMutableArray *myBullets = [[NSMutableArray alloc] init]; Create and then add the objects for (int i=0; i<5; i++){ //create Bullet  *newBullet = [[Bullet alloc] init]; //add to the array [myBullets addObject: newBullet]; //release the object here as its retained in the array  [newBullet release]; }``` `myBullets` now has 5 bullets in it. Then to modify the object: ```objectivec // Retrive an item theBullet = [myBullets objectAtIndex:i];...