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.
For the RotateViewFrom:... it's Objective-C code hung off the Application delegate.
- (void) rotateViewFrom: (UIView *) fromView toView: (UIView*) toView animationDuration: (double) animationDuration animationTransition: (int) animationTransition curve: (int) curve cached: (BOOL) cachedFlag { UIView * superViewtoUse = [fromView superview]; [UIView beginAnimations: nil context: nil]; [UIView setAnimationDelegate: self]; [UIView setAnimationWillStartSelector: @selector (animationWillStart:context:)]; [UIView setAnimationDuration: animationDuration]; [UIView setAnimationCurve: curve]; [UIView setAnimationTransition: animationTransition forView: superViewtoUse cache: cachedFlag]; [fromView removeFromSuperview]; [superViewtoUse addSubview: toView]; [UIView commitAnimations]; }