我能够在我的项目中实现下面提到的库。使用的库::https://github.com/rolandleth/LTHPasscodeViewController
在输入密码之后,在验证它是正确的之后,我无法在密码输入后切换到选项卡栏活动,但是如果我在中间使用NSNotification,我就可以转移控制。
我的代码:
- (void) receiveTestNotification:(NSNotification *) notification
{
if ([[notification name] isEqualToString:@"TestNotification"])
NSLog (@"Successfully received the test notification!");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
mainTabViewController *objSec=[storyboard instantiateViewControllerWithIdentifier:@"passID"];
[self.navigationController pushViewController:objSec animated:YES];在放置了一个NSLog之后,我得到了日志输出,但是选项卡视图没有出现。
有什么方法可以在输入针后直接调用选项卡视图吗?
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveTestNotification:)
name:@"TestNotification"
object:nil];使用StoryBoard完成Tabview。
发布于 2014-01-31 14:07:30
我认为发生这种情况是因为这个库的回调方法是在后台线程中执行的,尝试将您的代码与主线程上的调度包装在一起,它应该会有所帮助:
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
mainTabViewController *objSec=[storyboard instantiateViewControllerWithIdentifier:@"passID"];
[self.navigationController pushViewController:objSec animated:YES];
}];https://stackoverflow.com/questions/21481356
复制相似问题