Я работаю над приложением iOS, и я использую диск Google для доступа к моим файлам, файл регистрации и регистрации работает нормально, но я просто спрашиваю, как добавить кнопку отмены на границе раздела Вход предоставленной диска SDK Google см нижеGoogle Диска iOS SDK: Дисплей Отмена кнопки входа
как образ, вы видите, нет никакого способа, чтобы сделать cancel
или кнопку go back
.
Вот мой код
// verify if the user is already connected or not
- (void)checkIfIsConnected
{
// Check for authorization.
GTMOAuth2Authentication *auth =
[GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
clientID:kClientID
clientSecret:kClientSecret];
if ([auth canAuthorize]) {
[self isAuthorizedWithAuthentication:auth];
}else
{
[self ConnectToDrive];
}
}
- (GTLServiceDrive *)driveService {
static GTLServiceDrive *service = nil;
if (!service) {
service = [[GTLServiceDrive alloc] init];
// Have the service object set tickets to fetch consecutive pages
// of the feed so we do not need to manually fetch them.
service.shouldFetchNextPages = YES;
// Have the service object set tickets to retry temporary error conditions
// automatically.
service.retryEnabled = YES;
}
return service;
}
-(void) ConnectToDrive{
SEL finishedSelector = @selector(viewController:finishedWithAuth:error:);
GTMOAuth2ViewControllerTouch *authViewController =
[[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDrive
clientID:kClientID
clientSecret:kClientSecret
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:finishedSelector];
[self.fileManagementViewController presentModalViewController:authViewController animated:YES];
}
// Action executed after finishing the Authentication
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
[self.fileManagementViewController dismissModalViewControllerAnimated:YES];
if (error == nil) {
[self isAuthorizedWithAuthentication:auth];
}
}
- (void)isAuthorizedWithAuthentication:(GTMOAuth2Authentication *)auth {
[[self driveService] setAuthorizer:auth];
self.isAuthorized = YES;
[self loadDriveFiles];
}
так, что не так ??
благодарит за ответ, но можете ли вы дать мне точный путь к классу GTMOAuth2Authentication.m, потому что для меня я нашел его в источнике GTL/Common/OAuth2, но я не нашел функцию viewDidLoad на нем –
Я не имеют GTMOAuth2Authentication.m на GTLSource-> Common-> OAuth2-> Touch, но у меня есть только GTMOAuth2ViewControllerTouch.m, и я сделал это в нем, но ничего не изменилось –
@hatimhaffane приятель здесь проверить ---- GTLSource-> Common-> OAuth2- > Touch -> GTMOAuth2ViewControllerTouch.m. См. Мой обновленный ответ. – ChenSmile