UIPickerView – spinning multiple components

xcode

I found an interesting issues with the iPhone SDK and the UIPickerView

The didSelectRow method gets called after a users selects a new value on a picker wheel. The method knows what wheel (component) was spun and the index of the newly selected value. This works great for a picker with a single wheel. My picker had 5 wheels in it.

If I spun two components of the picker at the same time. I would only get one call to the didSelectRow method. More specifically, if I spin one component and move another component no call was received until the first component stops spinning, and so the second component move is never registered.

Long story short, I didn’t catch this problem when I submitted my app, “Ka-Ching”, to the iTunes store. As a result of not catching this, Apple rejected my app. I could argue that the iPhone SDK should have so programmatic hooks that would only allow one component to be spun at a time, or even a method to return the state of all of components in the picker.

uipickerview

Trying to figure out a solution to the problem I expanded on my idea of recording the state of all the components in the picker when the didSelectRow method was called. Realistically, by the time that didSelectRow gets processed it is possible that all 5 of the components had changed.

Looking through the SDK documentation for the UIPickerView I came across this:

- (NSInteger)selectedRowInComponent:(NSInteger)component

With this method you can determine the selected row index for any of the components in your picker. you don’t have to rely on the values passed into the didSelectRow method.

The wrong way to do it

- (void)pickerView:(UIPickerView *)thePickerView
 didSelectRow:(NSInteger)row
 inComponent:(NSInteger)component
{
	//get the value of the component that was changed
	if(component == 0)
	{
        	currency_value = [currency objectAtIndex:row];
	}
	else if(component == 1)
	{
        	hundereds_value = [hundereds objectAtIndex:row];

	}
	else if(component == 2)
	{
        	tens_value = [tens objectAtIndex:row];
	}

	else if(component == 3)
	{
        	ones_value = [ones objectAtIndex:row];
	}

	else if(component == 4)
	{
        	change_value = [cents objectAtIndex:row];
	}

	//some code here to save the values

}

The right way to do it

- (void)pickerView:(UIPickerView *)thePickerView
 didSelectRow:(NSInteger)row
 inComponent:(NSInteger)component
{

	//get the values
	NSInteger currency_NewRow = [thePickerView selectedRowInComponent:0];
	NSInteger hundereds_NewRow = [thePickerView selectedRowInComponent:1];
	NSInteger tens_NewRow = [thePickerView selectedRowInComponent:2];
	NSInteger ones_NewRow = [thePickerView selectedRowInComponent:3];
	NSInteger cents_NewRow = [thePickerView selectedRowInComponent:4];

	//some code to save the values 

}

NOW THIS WAR HAS TWO SIDES

I typically stay away from politically charged topics on my blog…

I went vegetarian in 1999, 10 years ago. In that time I have basically become vegan for all intensive purposes, but I have never labeled myself anything other then a strict vegetarian. I chose to stop eating meat as a symbol of my allegiance with animal rights, and as an economic protest against the factory farming industry.

Just because I don’t eat meat, it doesn’t mean that I’m a Hippy. Hippies are pacifists, I enjoy fighting and I support direct action. Direct action is not protesting, it’s actually doing something about the problem, physically going out and getting involved. The A.L.F. (Animal Liberation Front), E.L.F (Earth Liberation Front) and Sea Shepherds are organizations that you may have heard about in the news. Often these groups are referred to as Eco-Terrorists by those who don’t agree with their actions.

Recently the Sea Shepherd’s have been in the public spotlight with the reality television series, “Whale Wars“. The series chronicles the Sea Shepard’s as they travel into Antarctic waters to do battle with Japanese whalers. Some of the Sea Shepherds actions include tangling whaling boats propellers with cords and rope to immortalize them in the water, throwing stink bombs onto whalers decks, and ramming whaling ships with their own. The show has received criticism from both sides of the debate on commercial whaling, but regardless of the stance, it has raised awareness of what is taking place in the southern ocean, and that there are people who really are willing to risk their life’s to make a change. Even if you aren’t a fan of animal rights, it’s hard to watch a whale that’s running away, get a giant metal spike slammed through it’s body and slowly bleed to death. Because of video like this being shown on “Whale Wars”, the Sea Shepherds are getting a lot of momentum and support behind them.

SeaShepherd-1
Last Saturday, in Riverside California there was an art show / fund raiser to support Sea Shepperd. I was expecting there to be some people there, but I was completely blown away by the volume of people that turned out to support the cause. It was great to see what a little positive media exposure could do for a group of outlaw “eco-terrorists”. I wish I had some money to drop on some of the awesome art work that was on display.

seanNoFlyer

I first became aware of Sea Shepherd in the 90’s through the Hardcore music scene and a band Ignite. The singer, Zoli, was very active with the group and wrote a few songs about direct action

In Defense – “Education without action does nothing, Bulldozers broken down, destruction takes the day off, the tank is filled with dirt. Land locked and monkeywrenched…”.

I was happy to see that Zoli was at the event. I got to catch up with him for a moment. Hanging out with him unlocked a flood of memories that I had locked away.

The highlight of the evening was listening to the founder of Sea Shepherd, Captain Paul Watson, speak. He was on stage for about 30 minutes and spoke very frankly about the groups intentions and what they are doing to ramp up their efforts to defend the creatures of the sea. It was inspiring. I’m really looking forward to the next season of Whale Wars.

[youtube]http://www.youtube.com/watch?v=zHwBVjP4sfw[/youtube]

[youtube]http://www.youtube.com/watch?v=JE8yzoshCTg[/youtube]
I left the event feeling energized and renewed. It’s been a long time since I was really excited about animal rights and direct action. If I didn’t have obligations that required me to have a steady job, I could totally see me on a Sea Shepherd ship.

I think its fitting to end this blog post with a portion of a song from one of my favorite bands, “Earth Crisis”

rabbitUltramilitance

Legal channels have been exhausted.
Uncruel alternatives rejected.
Awareness created and ignored.
Direct action is the last recourse.
Ultramilitance, Ultramilitants.

Salvation of innocents.
Intensified resistance.
Flooded by sabotage, disabled whaling ships sink beneath the waves.
Strikes against roving murderers.
Through destruction, innocents persists…

…NOW THIS WAR HAS TWO SIDES!


RotoPhoto, my first iPhone app

WOW, here I am about to release my second iPhone app, and I realized that I haven’t blogged about my first iPhone app!

“RotoPhoto” is my first iPhone app. It’s a simple tool that allows you to rotate the orientation of a photo taken with the iPhone. The internal sensors of the iPhone are designed to know what direction is up at all times and auto rotate the iPhone camera for you, so no matter the angle you take the picture they are facing up. If you have owned an iPhone for an extended period of time, then you know that the iPhone can get confused when you take a picture when the camera is pointed down or up, and your picture comes out sideways. The iPhone doesnt have any built in facilities for adjusting your photos. RotoPhoto is a tool that fills that gap.

With RotoPhoto you can fix your photos orientation before sharing them with friends.

RotoPhoto is avaliable for $0.99 USD on the iTunes store.

app_store_badge_0708

You can check out http://RotoPhotoApp.com for more information

[youtube]http://www.youtube.com/watch?v=mIPvURe_AcE[/youtube]