Archive for the 'tips' Category

Show the Spinner on the Carrier Bar?

Try this:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

Fade Transition on iPhone

So you might have spent some time trying to figure out how to do a fade transition on iPhone. You probably found sample code and doc for things like curl and flip but not fade in/out, right? Well, it’s actually pretty simple:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
someView.alpha = 0.1;
[UIView commitAnimations];

Bam. You just faded from whatever prior alpha value was set on someView to 0.1 (10%) opacity. The setAnimationDuration method takes a float value in seconds. You could go all the way to 0 to hide it, or set it higher later to fade it back in. This means you can do something like this:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
someImageView.alpha = 0.0;
[UIView commitAnimations];

[someImageView setImage: [UIImage imageNamed:@"anotherImage.png"]];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
someView.alpha = 1.0;
[UIView commitAnimations];

to create a fade transition from one image to the next. The total time from hiding one image to seeing the next would be 1 second, in this case.

Branching with Versions

Wow. Sometimes things are so simple you don’t realize how to go about them. Earlier I stated that Versions lacked the ability to Branch/Tag in SVN. I was very wrong. All you have to do is select your repository bookmark to browse a given repo, drag your project’s trunk folder onto your branches/tags folder while holding the option key (you’ll see a green plus just like you do in finder) and let go of your mouse button. It’ll then ask for a commit comment and you’re done. It couldn’t possibly be simpler. Brilliant.

App:tip - 1 to n mapping of request to responses in Java

In some cases it`s useful to map a single incoming request to several responses. One such example is delegating to helper service methods. In Java, one can do this using the following basic pattern:

@Service(request = "my.request", response = "*")
public void myService(Message requestMessage, Message responseMessage) {
    String responseMessageType = "";
    if (some condition)
        responseMessageType = myServiceHelper(requestMessage, responseMessage);
    else
        responseMessageType = myOtherServiceHelper(requestMessage,responseMessage);

    responseMessage.setType(responseMessageType);
}

Obviously, the helpers above need to return a String with the appropriate message type (name). It is, of course, also possible to just set the type in the helper.

Also, the helpers should populate the data payload of the response (one reason for using this pattern).

IE does not like commas..

in the wrong places. Specifically, IE may fail to do what you want if you pass it something like:

var bleh = [1,2,3,4,5,];

Then try to do something with bleh. In the case of passing payloads to Appcelerator widgets (such as the datatable), the widget may fail to properly render (without error, since the execute function is never even called by IE’s js interpreter).