我只是构建一个类来正确管理我的数据库和JSON请求。问题是,现在,我该如何执行segue?
这是我的代码 在我看来:
void BindDataSource<T>(BindingList<T> list) where T : A { }
在我班上:
- (IBAction)loginClick:(id)sender
{
NSString *post = [NSString stringWithFormat:@"username=test&password=test"];
[[DataManagement sharedManager] WebServiceLogin:post];
}
- (void) showTypeView
{
[self performSegueWithIdentifier:@"showTypeView" sender:nil];
}
当我启动时,我有一个错误: **
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
...
switch ([[response valueForKey:@"success"] intValue])
{
case 0:
{
NSLog(@"error: %@ error Description: %@", [response valueForKey:@"success"], [response valueForKey:@"error_message"]);
break;
}
case 1:
{
LoginViewController *showView = [LoginViewController new];
[showView showTypeView];
break;
}
default:
break;
}
...
}
**
答案 0 :(得分:1)
如果你正在使用segueWithIdentifier,那么你需要已经在故事板中内置了segue并正确标记为&#34; showTypeView&#34;。否则,您应该使用导航控制器来推送视图控制器或使用self presentViewController来显示模态视图控制器。
编辑: 根据Larme的评论,你可以建立一个像这样的代表:
// In your class.h file
@property (weak, nonatomic)id<SegueDelegate> delegate;
// In class.m file
LoginViewController *showView = [LoginViewController new];
self.delegate = showView;
[self.delegate segue];
// In LoginViewController.h
@protocol SegueDelegate
-(void)segue;
@end
@interface LoginViewController: UIViewController <SegueDelegate>
-(void)segue;
@end
// In LoginViewController.m
@implementation LoginViewController
-(void)segue
{
[self performSegueWithIdentifier:@"showTypeView" sender:nil];
}
@end