Archive for the ‘Design’ Category

iOS: UIMenuController

Tuesday, June 12th, 2012

File this one under: For my own future reference.

UIMenuController was introduced as public API in iOS 3.0 (along with UIPasteboard and Copy and Paste functionality). This is now a technology we take for granted in the iOS world, but it really wasn’t that long ago that Apple hadn’t provided this seemingly basic service.

Recently I was using this API in DeepDish GigBook to update some fairly crufty workflow. I am not going to explain how to use UIMenuController, as the documentation is fairly straight forward. What I will mention is a few “gotchas”.

1. There is no target for an UIMenuItem.

It is whomever is the First Responder. In other words, your controller class probably (in most cases) is what will handle the actions, so you want to make sure it can become the first responder. Add the following to your controller implementation:

- (BOOL)canBecomeFirstReponder
{
    return YES;
}

IF you don’t do this, then passing the message -setMenuVisible:animated: to the UIMenuController will have no effect.

2. Implement - (BOOL)canPerformAction:(SEL) sender:(id) in your controller:

There is little reason not to, and many reason why you should. This will be implemented in the same controller that also implemented -canBecomeFirstResponder. This will allow you to enable or disable (effectively hiding) any menu options you may or may not want at any particular time. It avoids having to recreate the menu items list every time the user invokes your menu through whatever gesture.

- (BOOL)canPerformAction:(SEL)action sender:(id)sender
{
    if ( action == @selector(myMenuItemMethod:) ) {
        return YES;
    }
    else if (...) {
        return ...;
    }
    else {
        return [super canPerformAction:action sender:sender];
    }
}

Of course, there might be situations where the same view might support different menu configurations depending on some context, in which case you probably do need to rebuild the menu list each time. But in case where you don’t…

3. Remember that your menu items are persistent:

Whatever menu items you add will remain there until they are set again. If you think about it, this makes sense since UIMenuController is a singleton.

This one bit me due to two reasons. 1) I didn’t have -canPerformAction:sender: implemented, 2) I assumed that menu items list must be rebuilt prior to each invocation of the menu. What happened was a different subview was presented within the main view of the controller, and the subview contained an UITextView. When the user double tapped the text view, and had some text on their pasteboard, the Paste menu option was displayed, along with the other menu options already installed by an earlier menu displayed in the same view. Oops.

The first solution was to nil out the menuItems when the menu was dismissed. This seemed a bit of hack. The better solution was to follow item 2 above since my menu items never changed as long as I was in this particular view. In this case, since a subview only required the basic Copy, Cut, Paste, Select, Select All, etc. the controller would return NO when the controller itself was no longer the first responder. Revisiting our implementation of -canPerformAction:sender: from above:

- (BOOL)canPerformAction:(SEL)action sender:(id)sender
{
    if ( action == @selector(myMenuItemMethod:) ) {
        return [self isFirstResponder];
    }
    else if (...) {
        return ...;
    }
    else {
        return [super canPerformAction:action sender:sender];
    }
}

Cheers!

March 2011 Mobile Portland

Tuesday, March 29th, 2011

Last night I attended the Mobile Portland meeting held the fourth Monday of each month. This particular meeting was entitled “Mobile as a Platform for Change”.

Originally, I think the topic was to be solely about the new website RDTN.org that was developed by Uncorked Studios (great name!), and presented by Marcelino Alvarez. The website was developed to help track the recent increases of radiation being spewed into the air by the mostly destroyed Fukushima daiichi nuclear plant after the March 11th, 2011 9.0 earthquake in Northern Japan.

Later, Renny Gleeson, Global Digital Strategies Director at Wieden+Kennedy, as added to the lineup, talking about another aspect of mobile for change from his perspective of working with some of the largest consumer companies in the world.

Both had interesting topics and presentation, but honestly, Renny’s impressed upon me the most. Although, it seems a majority of his talk centered around Coca-cola (ah, refreshing) than any of the other brands. But, aside from this mono-corporate viewpoint, his talk was really interesting and thought provoking.

Did you know you can power a cell phone using a coca-cola for 5 hours? It is a bio-battery, and a concept prototype was created by Daizi Zheng. Perhaps the best use of that sugar-water. Although it begs the question, can a cell phone develop diabetes?

Nokia cell phone being powered by Coca-Cola.

Daizi Zheng's concept phone

 

In Africa, a doctor wanted to figure a way to keep vaccines from spoiling from lack of refrigeration while transporting them to other towns. He noticed that every day, a Coca-Cola truck came to make deliveries. These trucks were large refrigerators on wheels, and kept a consistent and timely distribution schedule. After much persuasion, he figured a way to piggy-back onto these transports by developing boxes that fit in the empty spaces between the bottle necks in the crates. ColaLife was born. That was thinking inside the box!

ColaLife.

2 billion servings of Coca-cola are consumed a day! Aside from the obvious threat to our health of drinking that much sugar water, the possibilities of spreading messages of good and hope on those containers are limitless.

The take-away messages was that social change and social good can come from large corporations, if only they can be convinced to harness the power of their established networks and incredible amounts of available cash (many with more money than the GDP of a lot of countries). However, more often than not, as demonstrated by the first two points, the ideas of change come from the outside, and rarely from the inside.

Why am I discussing Coca-cola in a blog about mobile software and my company?

Because, another number was tossed out.

5 Billion.

That is the number of mobile devices in active use. Much like a simple drink can change lives (and not necessarily by actually drinking it), the mobile phone also is providing amazing opportunities for social change, and not just a way to call someone or check your Twitter feed. It is already becoming a game changer in many of the Northern Africa countries, allowing the people to report the truth, and hopefully drive democratic reforms in those otherwise totalitarian nations.

Something to think about. After all, that’s what going to Mobile Portland is all about.

Tapworthy: The Essential iPhone Developer’s Book

Monday, August 2nd, 2010

“Tapworthy: Designing Great iPhone Apps”
by Josh Clark
http://oreilly.com/catalog/9781449381653
O’Reilly Media
320 pages
$39.99 dead-tree book
$31.99 digital book (look for periodic discount codes on http://oreilly.com)

Usually, when I seek out a technical book, I tend to look at what O’Reilly has to offer on the subject first. I have always found their books to be both informative, and usually actually fun to read… generally not an easy feat when it comes to technical subjects. Josh Clark’s recently published book, “Tapworthy: Designing Great iPhone Apps” continues this fine tradition.

After you have read Apple’s iPhone Human Interface Guidelines (usually referred as “HIG“), before you write a single line of code, and even before you start designing that next great app, take a short amount of time to read “Tapworthy”. It is a blend of philosophy, pragmatism, and enlightening First Person views into the development thought process of developers of some well known iPhone apps, including Twitterific, Gowalla, PCalc, and USA Today.

Note: Even if you are not writing an app targeted at the iPhone, but some other mobile platform, such as Android, WebOS, or Windows 7 Mobile, don’t let that deter you from reading this book. Apple went to a lot of trouble researching human interactions centered around the mobile form factor, and Mr. Clark brings much of the findings into the topics he covers. It won’t mean you’ll be writing an iPhone clone app, but an app that follows some logical, and reasonable, guidelines that will make the user experience that much better.

While I often tend to skip a books’s Introduction, don’t skip it in this book. The last section, “Advice from the Real World”, is worth half the price of the book alone. Copy this page and hand it to any prospective clients that come knocking at your door asking you to do their killer iPhone app idea, to give them a reality check on the time and effort to do it right:

Great apps seem effortless, and the best make it seem as if the design process came fast and easy. That’s rarely true. No matter how sensational the designer or developer, designing a great app takes hard work and careful consideration.

The first three chapters, “Touch and Go”, “Is It Tapworthy?”, and “Tiny Touchscreen” were the most thought provoking of the chapters, and are applicable to any small mobile platform. Here is where the philosophy of mobile app usage and development is addressed. As any good book, these chapters set up the basis for the remaining chapters where it is applied discussing the various flavors of content navigation models, controls indigenous to the iPhone, and general product presentation tips. The themes “Less is More”, and “Focus, focus, focus” emerge, and Mr. Clark’s helpful guidelines of, “Rule of Thumb”, “The Magic Number is 44″, and “Designing to a 44 Pixel Rhythm” all stand out and will go a long ways in helping the developer create an app that is not too busy, too crowded, or too difficult to use.

The remainder of the book covers the material that is found in Apple’s HIG documents, but in no way should it be considered a substitute, nor should it be passed over. On the contrary, they should both be read together, as they compliment each other. “Tapworthy” has many little gems sprinkled throughout these chapters that makes even an experienced developer think, “Ah ha!”. Subtle nuances of proper usage for various UI bits, working with gestures, working well with other apps, and general presentation. “Tapworthy” gives the “when” and “why”, whereas Apple’s HIG gives the “what” and “how”.

I thoroughly enjoyed reading “Tapworthy”. I find the end of chapter summary “Touchpoints” useful for returning back to refresh one’s memory on key concepts after having completed the book. The various diagrams used to help illustrate key points throughout the book were very helpful, although iBooks had some formatting issues. However, only once did I have to go to my physical iPhone to get an visual clarification. Each chapter was sure to contain a few little morsels of information that I could step back and apply immediately to my current project (even though it is for the iPad). I will certainly go back and review old shipping apps and apply retroactively as appropriate.

I particularly appreciated the interviews with other developers. Where it could have been a big ego-fest for them, in actuality each was enlightening and illuminating, and in some cases humbling as they revealed their early failings and missteps. While you might not 100% agree with their design decisions, you can understand where they were coming from.

I rate this book as a must read for any iPhone developer or prospective developer. Of particular value are the Introduction, and chapters 1 through 3, to any mobile app developer, iPhone or otherwise. I think it will be the rare developer that won’t learn something from this book that will make their product(s) that much better. At the very least, a developer will have a much better understanding of basis of various Human Interface Guidelines requirements that were conceived and established by Apple.

Once again, O’Reilly has published a book that broaden my knowledge and was compelling to read. I look forward to seeing if Josh Clark will come out with “Touchworthy: Designing Great iPad Apps” in the future. You hear it here first, folks.

This book, and this book review, was entirely read and written on an iPad using Apple’s Pages, then posted to this blog via the WordPress iPad app.