present 一个页面后 使用pushviewcontroller的问题

来源:互联网 发布:支持微信提现赚钱软件 编辑:程序博客网 时间:2024/05/18 02:20

       最近,做项目的时候遇到的,就是present 一个viewController 后,想在这个页面上pushviewcontroller 另一个页面,发现没有任何网页,遍搜所有国内的博客,都没发现有类似的问题,搜stackhack ,发现有类似的问题,经过本人的实验,终于解决了。现把解决方案贴在这里,以便于整理和学习。

      遇到这样的问题,貌似需要先把原先的viewcontroller dissmiss 掉,然后才能用push 的方法推出新的页面。啥都不说先贴代码

 1.  在present 一个viewController 前的那个页面

 

notiView= [[[NotifyViewController alloc]initWithNibName:@"NotifyViewController" bundle:nil]autorelease];  //  MainViewController *mainController =[MainViewController alloc] ini;    notiView.delegate=(id)self;    [self presentModalViewController:notiView animated:YES];    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{        sleep(1);                dispatch_async(dispatch_get_main_queue(), ^{            [self dismissModalViewControllerAnimated:NO];            [self.navigationController pushViewController:notiView animated:NO];        });    }); 在该页面实现delegate
- (void)didDissmissSearchViewController{    [self presentModalViewController:notiView animated:NO];    [self dismissModalViewControllerAnimated:YES];}

//2.在该viewcontroller关闭该页面的时候调用的,并且在该页面声明delegate

// [self dismissModalViewControllerAnimated:YES];    if (self.navigationController != nil) {        if ([delegate respondsToSelector:@selector(didDissmissSearchViewController)]) {            [self.navigationController popViewControllerAnimated:NO];            [delegate didDissmissSearchViewController];        }        else {            [self.navigationController popViewControllerAnimated:NO];        }    }

	
				
		
原创粉丝点击