Oct 23, 2012

Top iOS programming bloopers for this week

Posted Oct 23, 2012

These are my top iOS bloopers for this week (and corresponding fixes):

  1. For proper spacing of Toolbar Items in iOS you can use

    UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    //this will center-align myButton
    [self setToolbarItems:[NSArray arrayWithObjects: flexibleSpace, myButton, flexibleSpace, nil]];

    or you can also use

    UIBarButtonSystemItemFixedSpace system item and set the width.
  2. 2nd or Bottom Navigation Toolbar in a popover (UIPopoverController)

    It is actually the toolbar item of the navigation controller.

    Assuming you added a navigation controller in a popover for the title,
    using initWithContentViewController: [UINavigationController]

    To show bottom toolbar, just set the navigation controller's toolbarHidden to NO.
  3. When changing the width of a UIBarButton, I often try to find the frame, but it's not there. Apparently, just set it directly using setWidth method.
  4. Change Navigation Controller's Back Button Title or Text
    Just accessing the backBarButtonItem will not work, you have to set the button entirely.
     self.navigationItem.backBarButtonItem =
          [[[UIBarButtonItem alloc] initWithTitle:@"Back"
                   style: UIBarButtonItemStyleBordered
                   action:nil] autorelease];
  5. UIButton is not showing , also related topic: UIBarButtonItem not showing UIButton custom view

    [btn setBackgroundImage:image forState:UIControlStateNormal]
    instead of
    btn.imageView.image = .. //ugh

    The same way if title is not showing, use:
    [btn setTitle:itemTitle forState:UIControlStateNormal];
    instead of
    btn.titleLabel.text = ..

Oct 11, 2012

Show GSP directly in Grails 2

Posted Oct 11, 2012
Starting Grails 2.0, you cannot access GSP's directly when you type it in the url without defining it in url mappings. It has been disallowed since it's considered a security flaw of Grails 1.x. The side-effect is for simple static pages, it's a hassle to create mappings everytime.

Fortunately, Grails allows a simple workaround by using the UrlMappings.groovy. You just need to define one controller and make its actions accessible in url mappings configuration.

These are the steps I followed to quickly see all my root pages:
  1. Create a StaticViewController
  2. My UrlMappings.groovy contains:

Creating a controller is my preferred way, it's an additional step but my views are more manageable this way. 

For this example, I defined the following in my StaticViewController:
def index() {

def hello() {

Then added the ff gsps:

I can now access the following in my browser:

To make your urls more search engine friendly, you may also want to map urls that ends in "html" to your controller, just add this line in UrlMappings.groovy :

In this case, I'll be able to access:

src: http://grails.1312388.n4.nabble.com/Direct-linking-to-gsp-in-Grails-2-0-td4228929.html

Oct 5, 2012

How to force Google to reindex your site or blog - kind of

Posted Oct 5, 2012

Google Webmaster Tools has a page for submitting a url to Google. Google will queue then try to re-index the requested page, but it doesn't guarantee that it will do so. Here's the extracted disclaimer:

Google adds new sites to our index, and updates existing ones, every time we crawl the web. If you have a new URL, tell us about it here. We don't add all submitted URLs to our index, and we can't make predictions or guarantees about when or if submitted URLs will appear in our index.

I guess it means they will try their best! It's better than nothing :)

The full url of the tool is https://www.google.com/webmasters/tools/submit-url

Oct 1, 2012

Google Apps Free Edition

Posted Oct 1, 2012
I use Google Apps for my domain name purchases because it comes with the Google goodies and easy to integrate with their services like Blogger. Now, I can't find the free edition anywhere on their front page, it seems it has been deliberately removed, maybe to promote the paid version.

Good news is there's still a link to access the free version of Google Apps. As of writing (October, 2012), you can access it here:

Source: Tech Crunch