Friday, February 6, 2009

UIAlertViewDelegate & Quotes

Was able to bang out UIAlertViewDelegate aspect. Now the user is gets an alert when they try to reset the counts. Basically asking for a confirmation/cancellation. This was really easy. You just extend your ViewController, define your alertView method and you're done.

This calls and opens the Alert popup window!

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your title here"
message:@"Your message here!"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Yes, Reset!", nil];
[alert show];
[alert release];


This is the method where you define what happens when the user presses "Ok"

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1){ // 1 corresponds to the "ok" button!
// stuff here!
}
}



After that I added in a rudimentary quote handler. At first I kept getting a null object when I was reading the text file into the array. Then I realized my calls were looking in the Documents folder rather than in the App's bundle which is where the source file would be located. Fixed that. Now it works. I currently just have it cycling through the quotes once per poke. and using the modulus operator to cycle back to the beginning. I will make this more complicated later, so it doesn't just spit out the quote every time. I still haven't decided betwee random or regular intervals.

Monday, February 2, 2009

UIView beginAnimations c*ck block.

Well, it seems the problem I was having the other day was that I was calling my function from within a beginAnimations block. Naughty Mitch. But also naughty documentation. I have learned something new once again. My MainView and FlipsideView are playing nicely together now.

I have also add a reset count buttons to flipside statistics side, in case the user wishes to reset counts.

I have started to add the quotes window, using a UIWebView. The close window method is done and working and I need only add the quotes and decide on how often to show a quote. I can't decide between set number or random periodicity. Will abstract the code and try both.

Ordered an iPod Touch 16gb for testing. It's not an iPhone but, I have two reasons for waiting; A) new iPhone probably in June or July, B) don't really need a new cell phone right now.