Skip to content

Instantly share code, notes, and snippets.

@kent013
Created June 5, 2012 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kent013/2872624 to your computer and use it in GitHub Desktop.
Save kent013/2872624 to your computer and use it in GitHub Desktop.
(iOS)DropboxSDK1.2.3b1 + Add feature to push DBConnectView to specified UINavigationController
diff -crN -x '*Base64*' -x .DS_Store -x '*.pch' -x '*.plist' dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DBConnectController.m DropboxSDK/DBConnectController.m
*** dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DBConnectController.m 2012-06-05 11:38:42.000000000 +0900
--- DropboxSDK/DBConnectController.m 2012-06-05 13:16:39.000000000 +0900
***************
*** 37,42 ****
--- 37,43 ----
@implementation DBConnectController
@synthesize alertView;
+ @synthesize isModal;
- (void)setAlertView:(UIAlertView *)pAlertView {
if (pAlertView == alertView) return;
***************
*** 53,58 ****
--- 54,60 ----
if ((self = [super init])) {
self.url = connectUrl;
+ self.isModal = YES;
self.title = @"Dropbox";
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
***************
*** 267,273 ****
if ([webView isLoading]) {
[webView stopLoading];
}
! [self.navigationController dismissModalViewControllerAnimated:animated];
}
- (void)dismiss {
--- 269,279 ----
if ([webView isLoading]) {
[webView stopLoading];
}
! if(self.isModal){
! [self.navigationController dismissModalViewControllerAnimated:animated];
! }else{
! [self.navigationController popViewControllerAnimated:animated];
! }
}
- (void)dismiss {
diff -crN -x '*Base64*' -x .DS_Store -x '*.pch' -x '*.plist' dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DBSession+iOS.m DropboxSDK/DBSession+iOS.m
*** dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DBSession+iOS.m 2012-06-05 11:38:42.000000000 +0900
--- DropboxSDK/DBSession+iOS.m 2012-06-05 13:16:39.000000000 +0900
***************
*** 85,98 ****
} else {
urlStr = [NSString stringWithFormat:@"%@://%@/%@/connect_login?k=%@&s=%@&easl=1%@",
kDBProtocolHTTPS, kDBDropboxWebHost, kDBDropboxAPIVersion, consumerKey, secret, userIdStr];
! UIViewController *connectController = [[[DBConnectController alloc] initWithUrl:[NSURL URLWithString:urlStr]] autorelease];
! UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:connectController] autorelease];
! if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
! connectController.modalPresentationStyle = UIModalPresentationFormSheet;
! navController.modalPresentationStyle = UIModalPresentationFormSheet;
}
-
- [rootController presentModalViewController:navController animated:YES];
}
}
--- 85,105 ----
} else {
urlStr = [NSString stringWithFormat:@"%@://%@/%@/connect_login?k=%@&s=%@&easl=1%@",
kDBProtocolHTTPS, kDBDropboxWebHost, kDBDropboxAPIVersion, consumerKey, secret, userIdStr];
! DBConnectController *connectController = [[[DBConnectController alloc] initWithUrl:[NSURL URLWithString:urlStr]] autorelease];
! if([rootController isKindOfClass: [UINavigationController class]]){
! connectController.isModal = NO;
! UINavigationController *navController = (UINavigationController *)rootController;
! [navController pushViewController:connectController animated:YES];
! }else{
! connectController.isModal = YES;
! UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:connectController] autorelease];
! if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
! connectController.modalPresentationStyle = UIModalPresentationFormSheet;
! navController.modalPresentationStyle = UIModalPresentationFormSheet;
! }
!
! [rootController presentModalViewController:navController animated:YES];
}
}
}
diff -crN -x '*Base64*' -x .DS_Store -x '*.pch' -x '*.plist' dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DropboxSDK/DBConnectController.h DropboxSDK/DropboxSDK/DBConnectController.h
*** dropbox-ios-sdk-1.2.3-b1/DropboxSDK/Classes/DropboxSDK/DBConnectController.h 2012-06-05 11:38:42.000000000 +0900
--- DropboxSDK/DropboxSDK/DBConnectController.h 2012-06-05 13:16:39.000000000 +0900
***************
*** 10,13 ****
--- 10,15 ----
- (id)initWithUrl:(NSURL *)url;
+ @property (assign, nonatomic) BOOL isModal;
+
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment