在iOS中使用Twitter登录时,如何将一个视图控制器移动到另一个视图控制器
我是iOS的初学者,在我的项目中,我为用户提供了Twitter登录功能,当我们单击登录按钮时,我们会得到Twitter登录页面,如下面的屏幕所示 登录后,我点击Twitter登录页面中的在iOS中使用Twitter登录时,如何将一个视图控制器移动到另一个视图控制器,ios,objective-c,uiviewcontroller,Ios,Objective C,Uiviewcontroller,我是iOS的初学者,在我的项目中,我为用户提供了Twitter登录功能,当我们单击登录按钮时,我们会得到Twitter登录页面,如下面的屏幕所示 登录后,我点击Twitter登录页面中的AuthorizedApp按钮 然后我想移动另一个视图控制器(即ViewController1)。为此,我编写了一些代码,但使用这些代码,我无法将一个视图控制器移动到另一个视图控制器 注意:我的主要意图是当我单击“AuthorizedApp”按钮时,我想将ViewController移动到ViewControll
AuthorizedApp
按钮
然后我想移动另一个视图控制器(即ViewController1)。为此,我编写了一些代码,但使用这些代码,我无法将一个视图控制器移动到另一个视图控制器
注意:我的主要意图是当我单击“AuthorizedApp”按钮时,我想将ViewController移动到ViewController1
我的代码:
#导入“ViewController.h”
#导入“FHSTwitterEngine.h”
#导入“ViewController1.h”
@界面视图控制器()
@结束
@实现视图控制器
-(无效)viewDidLoad{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
[[FHSTwitterEngine sharedEngine]永久设置消费者市场:“《yyp5D4Elbo4fBAdnbnOZDaPRt》”和机密:“《WWIfOhVw8J0rillpQipz5r1dl44x4lH6Rky5glb1M4YM72》”;
[[FHSTwitterEngine sharedEngine]setDelegate:self];
[[FHSTwitterEngine sharedEngine]loadAccessToken];
//google plus登录按钮
UIButton*button=[UIButton button类型:UIButtonTypeCustom];
[按钮添加目标:自我
操作:@selector(loginOAuth)
forControlEvents:UIControlEventTouchUpInside];
[按钮设置图像:[UIImage ImageName:@“twitter icon.png”]用于状态:UIControlStateNormal];
button.frame=CGRectMake(170,200,40,40);
CALayer*d=[按钮层];
[d setMasksToBounds:是];
[d:半径:20];
[self.view addSubview:按钮];
}
-(无效)loginOAuth{
UIViewController*loginController=[[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(布尔成功){
NSLog(成功?@“L0L成功”:“不!!!洛根·费勒!!!”;
NSLog(@“用户名-->>>%@”,FHSTwitterEngine.sharedEngine.authenticatedUsername);
NSLog(@“用户id-->%@”,FHSTwitterEngine.sharedEngine.authenticatedID);
ViewController1*dvc=[self.storyboard实例化eviewcontrollerwhiteIdentifier:@“ViewController1”];
[dvc SetModAltTransitionStyle:UIModAltTransitionStyleCoverVertical];
[自我呈现视图控制器:dvc动画:是完成:无];
}];
[自我呈现视图控制器:loginController动画:是完成:无];
}
您应该在视图控制器之间建立segue连接,并为segue提供一个标识符。之后,您可以将performsguewithidentifier方法与您的segue标识符名称一起使用。就你而言
- (void)loginOAuth {
UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
NSLog(@"User name ---->>>%@",FHSTwitterEngine.sharedEngine.authenticatedUsername);
NSLog(@"User id ------> %@",FHSTwitterEngine.sharedEngine.authenticatedID);
// These codes work on background thread you should move them to the main thread
/*ViewController1 *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
[dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:dvc animated:YES completion:nil];*/
}];
[self performSegueWithIdentifier:@"yourSegueIdentifierYouMustChange" sender:self]; // or sender nil
}
如果performsguewithidentifier方法无法解决您的问题,我们可以尝试将您的代码移动到主线程。不,它不起作用,我的主要要求是当我单击授权应用程序按钮时,我希望显示用户详细信息,然后移动另一个视图控制器
- (void)loginOAuth {
UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
NSLog(@"User name ---->>>%@",FHSTwitterEngine.sharedEngine.authenticatedUsername);
NSLog(@"User id ------> %@",FHSTwitterEngine.sharedEngine.authenticatedID);
// These codes work on background thread you should move them to the main thread
/*ViewController1 *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
[dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:dvc animated:YES completion:nil];*/
}];
[self performSegueWithIdentifier:@"yourSegueIdentifierYouMustChange" sender:self]; // or sender nil
}