Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

iOS 5.0 rotation: fix problems with signature capture and map view

  • Loading branch information...
commit 7d52f8e4d1cb58ad5e8c88a5533db6ac82651da4 1 parent 24daf6b
@mmalinin mmalinin authored
View
2  platform/iphone/Classes/AppManager/AppManager.m
@@ -428,7 +428,7 @@ - (void) configure:(BOOL)make_sym_links force_update_content:(BOOL)force_update_
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
- return [[Rhodes sharedInstance] mainView];
+ return [[Rhodes sharedInstance] baseViewController];
}
View
13 platform/iphone/Classes/MapView/MapViewController.m
@@ -55,7 +55,7 @@ + (void)run:(NSValue*)value {
}
MapViewController* map = [[MapViewController alloc] init];
[map setParams:[value pointerValue]];
- UIWindow *window = [[Rhodes sharedInstance] rootWindow];
+ UIView* rootView = [[Rhodes sharedInstance] rootView];
map.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
map.view.autoresizesSubviews = YES;
@@ -63,9 +63,9 @@ + (void)run:(NSValue*)value {
map.savedMainView = v;
[map.savedMainView retain];
[map.savedMainView removeFromSuperview];
- [window addSubview:map.view];
- //window.autoresizesSubviews = YES;
- //[window layoutSubviews];
+ [rootView addSubview:map.view];
+ //rootView.autoresizesSubviews = YES;
+ //[rootView layoutSubviews];
mc = map;
}
@@ -115,10 +115,11 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- (void)close {
[self dismissModalViewControllerAnimated:YES];
- UIWindow *window = [[Rhodes sharedInstance] rootWindow];
+ UIView* rootView = [[Rhodes sharedInstance] rootView];
- [window addSubview:self.savedMainView];
+ [rootView addSubview:self.savedMainView];
+ [rootView layoutSubviews];
[self.view removeFromSuperview];
[self.savedMainView release];
View
11 platform/iphone/Classes/MapView/RhoMapViewController.m
@@ -51,7 +51,7 @@ + (void)run:(NSValue*)value {
}
RhoMapViewController* map = [[RhoMapViewController alloc] init];
[map setParams:[value pointerValue]];
- UIWindow *window = [[Rhodes sharedInstance] rootWindow];
+ UIView *rootView = [[Rhodes sharedInstance] rootView];
map.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
map.view.autoresizesSubviews = YES;
@@ -59,7 +59,8 @@ + (void)run:(NSValue*)value {
map.savedMainView = v;
[map.savedMainView retain];
[map.savedMainView removeFromSuperview];
- [window addSubview:map.view];
+ [rootView addSubview:map.view];
+ [rootView layoutSubviews];
mc = map;
}
@end
@@ -104,11 +105,11 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- (void)close {
[self dismissModalViewControllerAnimated:YES];
- UIWindow *window = [[Rhodes sharedInstance] rootWindow];
+ UIView *rootView = [[Rhodes sharedInstance] rootView];
-
- [window addSubview:self.savedMainView];
+ [rootView addSubview:self.savedMainView];
[self.view removeFromSuperview];
+ [rootView layoutSubviews];
[self.savedMainView release];
self.savedMainView = nil;
View
4 platform/iphone/Classes/RhoViewController.h
@@ -41,3 +41,7 @@
#endif
@end
+
+@interface RhoRootViewController : RhoViewController {}
+
+@end
View
112 platform/iphone/Classes/RhoViewController.m
@@ -26,6 +26,7 @@
#import "Rhodes.h"
#import "RhoViewController.h"
+#include "common/RhodesApp.h"
@implementation RhoViewController
@@ -68,3 +69,114 @@ - (NSUInteger)supportedInterfaceOrientations
#endif
@end
+
+
+int rho_sys_get_screen_width();
+int rho_sys_get_screen_height();
+
+
+@implementation RhoRootViewController
+
+- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+{
+ UIInterfaceOrientation current_orientation = [[UIApplication sharedApplication] statusBarOrientation];
+ if (current_orientation == fromInterfaceOrientation) {
+ return;
+ }
+ int width = rho_sys_get_screen_width();
+ int height = rho_sys_get_screen_height();
+ // send after rotate message
+ //CGRect wFrame = [webView frame];
+ int angle = 0;
+ switch (fromInterfaceOrientation) {
+ case UIInterfaceOrientationPortrait: {
+ switch (current_orientation) {
+ case UIInterfaceOrientationLandscapeLeft: {
+ angle = 90;
+ }
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown: {
+ angle = 180;
+ }
+ break;
+ case UIInterfaceOrientationLandscapeRight: {
+ angle = -90;
+ }
+ break;
+
+ default:
+ angle = 0;
+ }
+ }
+ break;
+ case UIInterfaceOrientationLandscapeLeft: {
+ switch (current_orientation) {
+ case UIInterfaceOrientationPortrait: {
+ angle = -90;
+ }
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown: {
+ angle = 90;
+ }
+ break;
+ case UIInterfaceOrientationLandscapeRight: {
+ angle = 180;
+ }
+ break;
+
+ default:
+ angle = 0;
+ }
+ }
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown: {
+ switch (current_orientation) {
+ case UIInterfaceOrientationPortrait: {
+ angle = 180;
+ }
+ break;
+ case UIInterfaceOrientationLandscapeLeft: {
+ angle = -90;
+ }
+ break;
+ case UIInterfaceOrientationLandscapeRight: {
+ angle = 90;
+ }
+ break;
+
+ default:
+ angle = 0;
+ }
+ }
+ break;
+ case UIInterfaceOrientationLandscapeRight: {
+ switch (current_orientation) {
+ case UIInterfaceOrientationPortrait: {
+ angle = 90;
+ }
+ break;
+ case UIInterfaceOrientationLandscapeLeft: {
+ angle = 180;
+ }
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown: {
+ angle = -90;
+ }
+ break;
+
+ default:
+ angle = 0;
+ }
+ }
+ break;
+ }
+ //if ((current_orientation == UIInterfaceOrientationLandscapeLeft) || (current_orientation == UIInterfaceOrientationLandscapeRight)) {
+ // int t = width;
+ // width = height;
+ // height = t;
+ //}
+ //rho_rhodesapp_callScreenRotationCallback((int)wFrame.size.width, (int)wFrame.size.height, angle);
+ rho_rhodesapp_callScreenRotationCallback(width, height, angle);
+}
+
+@end
View
2  platform/iphone/Classes/Rhodes.h
@@ -97,7 +97,7 @@
+(void)restart_app;
-- (UIWindow*)rootWindow;
+- (UIView*)rootView;
- (void)playStart:(NSString*)fileName mediaType:(NSString*)type;
- (void)playStop;
View
12 platform/iphone/Classes/Rhodes.m
@@ -376,7 +376,7 @@ -(BOOL)startCameraPicker:(PickImageDelegate*)delegateObject
}
//[window addSubview:picker.view];
- [[mainView getMainViewController] presentModalViewController:picker animated:NO];
+ [baseViewController presentModalViewController:picker animated:NO];
}
} @catch(NSException* theException) {
RAWLOG_ERROR2("startCameraPickerFromViewController failed(%s): %s", [[theException name] UTF8String], [[theException reason] UTF8String] );
@@ -410,9 +410,7 @@ - (void)takeSignature:(NSString*)url {
SignatureViewController* svc = [[SignatureViewController alloc] initWithRect:rect delegate:signatureDelegate];
[signatureDelegate setSignatureViewControllerValue:svc];
- [[mainView getMainViewController] presentModalViewController:svc animated:YES];
-
-
+ [baseViewController presentModalViewController:svc animated:YES];
//[mainView.view retain];
//[mainView.view removeFromSuperview];
@@ -483,8 +481,8 @@ - (void)choosePicture:(RhoCameraSettings*) settings {
sourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
-- (UIWindow*)rootWindow {
- return window;
+- (UIView*) rootView {
+ return baseView;
}
- (void)hideSplash {
@@ -682,7 +680,7 @@ - (void)doStartUp {
window = [self createWindow];
/************************/
- baseViewController = [[RhoViewController alloc] init];
+ baseViewController = [[RhoRootViewController alloc] init];
CGRect wFrame = [Rhodes applicationFrame];
wFrame.origin.x = 0;
View
4 platform/iphone/Classes/Signature/SignatureDelegate.m
@@ -131,7 +131,7 @@ - (void)useImage:(UIImage*)theImage {
}
-(void)doDone:(UIImage*)image {
- [[[[Rhodes sharedInstance] mainView] getMainViewController] dismissModalViewControllerAnimated:YES];
+ [[[Rhodes sharedInstance] baseViewController] dismissModalViewControllerAnimated:YES];
[self useImage:image];
//[signatureViewController.view removeFromSuperview];
[signatureViewController release];
@@ -143,7 +143,7 @@ -(void)doDone:(UIImage*)image {
}
-(void)doCancel {
- [[[[Rhodes sharedInstance] mainView] getMainViewController] dismissModalViewControllerAnimated:YES];
+ [[[Rhodes sharedInstance] baseViewController] dismissModalViewControllerAnimated:YES];
rho_rhodesapp_callSignatureCallback([postUrl UTF8String], "", "", 1);
//[signatureViewController.view removeFromSuperview];
[signatureViewController release];
View
97 platform/iphone/Classes/SimpleMainView.m
@@ -48,9 +48,6 @@
#define RHO_TAG_TOOLBAR 2
#define RHO_TAG_NAVBAR 3
-int rho_sys_get_screen_width();
-int rho_sys_get_screen_height();
-
@interface RhoToolbarButtonItemAction : NSObject
{
NSString *url;
@@ -425,96 +422,6 @@ - (void)loadView {
assert([root retainCount] == 1);
}
-- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
-{
- UIInterfaceOrientation current_orientation = [[UIApplication sharedApplication] statusBarOrientation];
- if (current_orientation == fromInterfaceOrientation) {
- return;
- }
- int width = rho_sys_get_screen_width();
- int height = rho_sys_get_screen_height();
- // send after rotate message
- //CGRect wFrame = [webView frame];
- int angle = 0;
- switch (fromInterfaceOrientation) {
- case UIInterfaceOrientationPortrait: {
- switch (current_orientation) {
- case UIInterfaceOrientationLandscapeLeft: {
- angle = 90;
- }
- break;
- case UIInterfaceOrientationPortraitUpsideDown: {
- angle = 180;
- }
- break;
- case UIInterfaceOrientationLandscapeRight: {
- angle = -90;
- }
- break;
- }
- }
- break;
- case UIInterfaceOrientationLandscapeLeft: {
- switch (current_orientation) {
- case UIInterfaceOrientationPortrait: {
- angle = -90;
- }
- break;
- case UIInterfaceOrientationPortraitUpsideDown: {
- angle = 90;
- }
- break;
- case UIInterfaceOrientationLandscapeRight: {
- angle = 180;
- }
- break;
- }
- }
- break;
- case UIInterfaceOrientationPortraitUpsideDown: {
- switch (current_orientation) {
- case UIInterfaceOrientationPortrait: {
- angle = 180;
- }
- break;
- case UIInterfaceOrientationLandscapeLeft: {
- angle = -90;
- }
- break;
- case UIInterfaceOrientationLandscapeRight: {
- angle = 90;
- }
- break;
- }
- }
- break;
- case UIInterfaceOrientationLandscapeRight: {
- switch (current_orientation) {
- case UIInterfaceOrientationPortrait: {
- angle = 90;
- }
- break;
- case UIInterfaceOrientationLandscapeLeft: {
- angle = 180;
- }
- break;
- case UIInterfaceOrientationPortraitUpsideDown: {
- angle = -90;
- }
- break;
- }
- }
- break;
- }
- //if ((current_orientation == UIInterfaceOrientationLandscapeLeft) || (current_orientation == UIInterfaceOrientationLandscapeRight)) {
- // int t = width;
- // width = height;
- // height = t;
- //}
- //rho_rhodesapp_callScreenRotationCallback((int)wFrame.size.width, (int)wFrame.size.height, angle);
- rho_rhodesapp_callScreenRotationCallback(width, height, angle);
-}
-
- (id)initWithParentView:(UIView *)p frame:(CGRect)frame bar_info:(NSDictionary*)bar_info {
return [self init:p webView:nil frame:frame bar_info:bar_info web_bkg_color:nil];
}
@@ -704,6 +611,7 @@ -(void)restoreWebView {
webView.frame = rect;
[root addSubview:webView];
+ [root layoutSubviews];
}
if (nativeView != nil) {
[RhoNativeViewManagerOC destroyNativeView:nativeView];
@@ -722,6 +630,8 @@ -(void)openNativeView:(UIView*)nv_view tab_index:(int)tab_index {
nativeViewView.clipsToBounds = NO;
nativeViewView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:nativeViewView];
+ [self.view layoutSubviews];
+
self.urlBasedNativeView = NO;
}
}
@@ -776,6 +686,7 @@ - (NSString*)processForNativeView:(NSString*)url {
//w.delegate = self;
nativeViewView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[root addSubview:nativeViewView];
+ [root layoutSubviews];
self.urlBasedNativeView = YES;
}
[nativeView navigate:navto];
Please sign in to comment.
Something went wrong with that request. Please try again.