我正在构建一个 iOS 应用程序。我已经在我的应用程序中实现了 Facebook 和 Twitter 集成。
我在 viewcontroller 中遇到了一个问题,我有按钮 Next 并实现了一个 push segue 在该按钮上继续下一个 View ,但是当我单击“下一步”按钮并出现错误时,我的应用程序崩溃了。
错误:由于未捕获的异常“NSGenericException”而终止应用程序,原因:“无法找到 segue ‘nextSport’的导航 Controller 。”只有当源 Controller 由 UINavigationController 的实例管理时,才能使用推送转场。'
这是 Storyboard的截图:
上一张图片:
添加了当前(新)图像:
这是我的代码:
- (IBAction)fbLogin:(id)sender {
[FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_location",@"user_birthday",@"user_hometown"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
switch (state) {
case FBSessionStateOpen:
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
NSLog(@"error:%@",error);
}
else
{
// retrive user's details at here as shown below
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *FBuser, NSError *error) {
if (error) {
// Handle error
}
else {
NSString *userName = [FBuser name];
NSLog(@"username===%@",userName);
NSLog(@"sesseion=%@",session);
}
}];
NSLog(@"FB user first name:%@",user.first_name);
userName=user.first_name;
NSLog(@"FB user last name:%@",user.last_name);
NSLog(@"FB user birthday:%@",user.birthday);
NSLog(@"FB user location:%@",user.location);
NSLog(@"FB user username:%@",user.username);
NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
NSLog(@"email id:%@",[user objectForKey:@"email"]);
NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
user.location[@"name"]]);
userImageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", [user objectID]];
NSLog(@"image=%@",userImageURL);
}
[self performSegueWithIdentifier:@"afterLogin" sender:nil];
}];
break;
}
} ];
}
最佳答案
您正在推送到 UINavigationController
,但执行推送的 viewController 也应该位于 UINavigationController
内。由于错误表明没有 UINavigationController
来执行 segue 'nextSport'
关于ios - 如何在按钮点击时实现 segue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26338494/