Revision [358]
This is an old revision of ViewTransition made by JohnMcIntosh on 2009-09-09 11:35:43.
a custom UIWebView. This starts over in the subclass of SqueakProxy where pressing the (i) generates
a smalltalk message to trigger infoButtonWasPressed:
infoButtonWasPressed: aButton infoButtonPressed := true.
this lets us remember that the button was pressed but we can't do the UIKit work until the callback finishes
so we do that chore in postLockProcessing, where we look for the state change, reset and call the ui handler to do the
transition
MyApplicationSqueakProxySubClass>>postLockProcessing self infoButtonPressed ifTrue: [self infoButtonPressed: false. ui doTransitionToInfoView].
doTransitionToInfoView | menuBar infoViewDoneButton | ObjectiveCBridge performSelectorOnMainThread: [self infoViewController ifNil: [| infoViewDoneButtonString | self loadInfoNIBFile. menuBar := self infoViewController view viewWithTag: 5. infoViewDoneButton := menuBar topItem rightBarButtonItem. infoViewDoneButtonString := 'infoViewDoneButtonWasPressed:'. self squeakProxy addSigViaString: infoViewDoneButtonString aSignature: 'v@:@'. infoViewDoneButton setTarget: self squeakProxy squeakProxy. infoViewDoneButton setAction: (ObjectiveCBridge findSelectorCalled: infoViewDoneButtonString)]. self sharedApplication delegate rotateViewFrom: self keypadController view toView: self infoViewController view animationDuration: 0.75 animationTransition: 2 curve: 3 cached: true asObjc. self sharedApplication setStatusBarHidden: false asObjc animated: true asObjc].
Now there are a number of complex things going on here, obviously I could use lazy initialization method to initialize the infoViewController,
so when we first come in we have to create the controller.
loadInfoNIBFile | infoString | infoString := 'InfoView' asNSStringUTF8. infoViewController := (ObjectiveCBridge classObjectForName: #RotatingViewControllerWithUIWebDelegate) alloc initWithNibName: infoString bundle: (ObjectiveCBridge classObjectForName: 'NSBundle') mainBundle. infoString release.
To create the controller we just load the nib file "InfoView" next we need to adjust the Done button behavior
menuBar := self infoViewController view viewWithTag: 5. infoViewDoneButton := menuBar topItem rightBarButtonItem. infoViewDoneButtonString := 'infoViewDoneButtonWasPressed:'. self squeakProxy addSigViaString: infoViewDoneButtonString aSignature: 'v@:@'. infoViewDoneButton setTarget: self squeakProxy squeakProxy. infoViewDoneButton setAction: (ObjectiveCBridge findSelectorCalled: infoViewDoneButtonString)].
First we have to get the menuBar, we have in the nib file placed the menu bar then assigned a TAG number, so we can ask for component number 5.
Then we ask for the topItem's rightBarButtonItem. This is all UIKit work so note how it's performed in a performSelectorOnMainThread: block.
we then setup the MyApplicationSqueakProxySubClass instance we have called squeakProxy to understand that on a button tap it should send the message infoViewDoneButtonWasPressed: to the MyApplicationSqueakProxySubClass instance's squeakProxy instance var.
So when the person taps the button then
MyApplicationSqueakProxySubClass>>infoViewDoneButtonPressed: aValue infoViewDoneButtonPressed := aValue MyApplicationSqueakProxySubClass>>postLockProcessing self infoViewDoneButtonPressed ifTrue: [self infoViewDoneButtonPressed: false. ui doTransitionToStatusViewFromInfoView].
which follows the same pattern as the infoButtonPressed logic
Where we rotate the keypad view back into place. Then we'e made an explicit decision to release the infoViewController and set it to nil in order to
fulliy release the memory used by the controller back to Objective-C.
doTransitionToStatusViewFromInfoView ObjectiveCBridge performSelectorOnMainThread: [self sharedApplication delegate rotateViewFrom: self infoViewController view toView: self keypadController view animationDuration: 0.75 animationTransition: 1 curve: 3 cached: false asObjc. self sharedApplication setStatusBarHidden: true asObjc animated: true asObjc. self infoViewController release.]. self infoViewController: nil.