ios - 关于UIscrollView里面放tableView,push跳转不了的问题.
大家讲道理
大家讲道理 2017-04-18 09:05:55
0
3
365

项目演示GIF图:
http://ww1.sinaimg.cn/large/70421ae5jw1f43m036b22g20b50iknpd.gif

应该怎么做,我知道要这个项目要用2个scrollView.
"最新"这个页面是在stroyboard里面创建的视图,
"视频"是用代码创建再用通知的方法实现点击cell跳转新页面的.

"最新"页面点击cell的跳转代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    latestWebView *webView = [[latestWebView  alloc] init];
    webView.hidesBottomBarWhenPushed = YES;
    webView.urlDetial = self.urlAry[indexPath.row];
    
    [self.navigationController pushViewController:webView animated:YES];
    
    NSLog(@"navigationController:  %@",self.navigationController);
}

"视频"页面的点击cell跳转代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   
    [[NSNotificationCenter defaultCenter] postNotificationName:@"noHideen" object:nil];
}

下面是在AppDelegate里面创建的主视图(MainViewController):

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];

MainViewController * mainvc = [[MainViewController alloc] init];

UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:mainvc];

self.window.rootViewController = nvc;

[self.window makeKeyAndVisible];

MainViewController的scrollView里面添加的各个视图:

[self.vcScrollview addSubview:self.nearbyVC.view];
[self.vcScrollview addSubview:self.latestVC.view];
[self.vcScrollview addSubview:self.videoVC.view];
[self.vcScrollview addSubview:self.collectionVC.view];

这样做以后发现点击tableView的Cell的时候push不了新页面(打印没有navigation),要用通知的方法才能实现push跳转:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tiaozhuan:) name:@"tiao" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tiaozhuan:) name:@"noHideen" object:nil];

 (void)tiaozhuan:(NSNotification *)notifiction
{
    NSLog(@"%@",notifiction.object);
    
    if (notifiction.object == nil) {
        self.barScrollview.hidden = NO;
    }
    else{
        
    testViewController * tes = [[testViewController alloc] init];
    
    self.barScrollview.hidden = YES;
    [self.navigationController pushViewController:tes animated:YES];
        
    }
}

1:我如果一定要实现点击cell以后push一个新页面. 是不是只能用通知的方法去实现?
2:不然的话只能在MainViewController里面创建几个tableView了(这样MainViewController肯定会很臃肿).
3:这个项目真的很简单,被困扰了一个星期,作为初学者很受打击,麻烦各位帮帮忙,或者您有更好的办法也请告知,谢谢.
描述得有点乱,万分感谢.需要源码的加我QQ 1404565175

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

모든 응답(3)
迷茫

몇가지 질문


    가장 큰 요구 사항 중 하나는 n개의 뷰 컨트롤러를 관리하는 것입니다. 성능을 보장하는 방법은 재사용 가능해야 하며 한 번에 로드할 수 없습니다.
  1. MainVC는 구성요소화되어야 합니다. 아래의 스크롤 viewController를 관리하려면 포함 viewcontroller를 정의하세요(구현 후 최적화)
  2. NetEase News를 모방한 데모가 인터넷에 많이 있습니다.
大家讲道理

패스를 건너뛰지 않는다면.
1.self.navigationController는 비어 있을 수 있으며 인쇄할 수 있습니다. 비어 있으면 컨트롤러가 더 이상 NavigationController가 아닙니다. 그래서 점프를 못해요.

  1. -(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath가

을 호출하지 않았습니다.
黄舟

"최신" 페이지에서 mainVC가 아닌 테이블뷰가 위치한 컨트롤러인 셀에서 self.navigationController를 클릭하고 메인 네비게이션 컨트롤러를 가져와서 점프해야 합니다

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿