Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单独使用WMZPageView + 使用UIView作为底部视图 悬停效果 ,view内的滚动视图上下滚动会影响 总体滚动 #120

Open
Lpkiki opened this issue Jan 9, 2024 · 2 comments

Comments

@Lpkiki
Copy link

Lpkiki commented Jan 9, 2024

需要加入 在VC中加入 [self.pageView performSelector:@selector(scrollViewDidScroll:) withObject:scrollView]; 解决问题(参考的WMZPageController)

大佬是不是我用的不对 ,你看下代码

`- (void)viewDidLoad {
[super viewDidLoad];

WMZPageParam *param = PageParam()
.wMenuHeadViewSet(^UIView *{
    UIImageView *image = [UIImageView new];
    [image sd_setImageWithURL:[NSURL URLWithString:@"https://upload-images.jianshu.io/upload_images/9163368-02e26751674a3bc6.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"]];
    image.frame = CGRectMake(0, 0, PageVCWidth, 300);
    return image;
})


.wTitleArrSet(@[@"精选",@"好货",@"精选",@"好货"])
.wViewControllerSet(^UIViewController * _Nullable(NSInteger index) {

// return NSClassFromString(@"TopSuspensionVC").new;
/// 带滚动视图需实现协议
TopSuspensionView *view = TopSuspensionView.new;

    view.page = index;
    /// 这里为了方便使用 使用同一个属性 所以这里为了去除警告强转一下类型 但是实际类型还是UIView
    return (UIViewController*)view;
})


.wTopSuspensionSet(YES)

// .wMenuHeightSet(50)

// .wTopSuspensionSet(YES)
// //No为从自定义导航栏顶部开始 yes为从自定义导航栏底部开始
// // .wFromNaviSet(NO)
// //顶部可下拉
// // .wBouncesSet(NO)

;

/// frame可以设置任意frame autoFix为YES
self.pageView = [[WMZPageView alloc]initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, self.view.bounds.size.height - 200) autoFix:NO param:param parentReponder:self];
self.pageView.downSc.dataSource = self ;
self.pageView.downSc.delegate = self ;
[self.view addSubview:self.pageView];


param.wEventClickSet(^(id  _Nullable anyID, NSInteger index) {
    NSLog(@"%@ %ld",self.pageView.upSc.currentVC,self.pageView.upSc.currentTitleIndex);
});


/// autoFix为NO 自己调整frame

// WMZPageView *pageView = [[WMZPageView alloc]initWithFrame:CGRectMake(0, 0, PageVCWidth, PageVCHeight - PageVCNavBarHeight) autoFix:NO param:param parentReponder:self];
// [self.view addSubview:pageView];
}

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = @"自定义视图";
    cell.detailTextLabel.text = @"自定义cell";
    return cell;
    }

  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 100;
    }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
    }

//注释这段代码会出现 滚动冲突

  • (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.pageView performSelector:@selector(scrollViewDidScroll:) withObject:scrollView];
    }

`

@wwmz
Copy link
Owner

wwmz commented Jan 19, 2024

需要加入 在VC中加入 [self.pageView performSelector:@selector(scrollViewDidScroll:) withObject:scrollView]; 解决问题(参考的WMZPageController)

大佬是不是我用的不对 ,你看下代码

`- (void)viewDidLoad { [super viewDidLoad];

WMZPageParam *param = PageParam()
.wMenuHeadViewSet(^UIView *{
    UIImageView *image = [UIImageView new];
    [image sd_setImageWithURL:[NSURL URLWithString:@"https://upload-images.jianshu.io/upload_images/9163368-02e26751674a3bc6.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"]];
    image.frame = CGRectMake(0, 0, PageVCWidth, 300);
    return image;
})


.wTitleArrSet(@[@"精选",@"好货",@"精选",@"好货"])
.wViewControllerSet(^UIViewController * _Nullable(NSInteger index) {

// return NSClassFromString(@"TopSuspensionVC").new; /// 带滚动视图需实现协议 TopSuspensionView *view = TopSuspensionView.new;

    view.page = index;
    /// 这里为了方便使用 使用同一个属性 所以这里为了去除警告强转一下类型 但是实际类型还是UIView
    return (UIViewController*)view;
})


.wTopSuspensionSet(YES)

// .wMenuHeightSet(50)

// .wTopSuspensionSet(YES) // //No为从自定义导航栏顶部开始 yes为从自定义导航栏底部开始 // // .wFromNaviSet(NO) // //顶部可下拉 // // .wBouncesSet(NO)

;

/// frame可以设置任意frame autoFix为YES
self.pageView = [[WMZPageView alloc]initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, self.view.bounds.size.height - 200) autoFix:NO param:param parentReponder:self];
self.pageView.downSc.dataSource = self ;
self.pageView.downSc.delegate = self ;
[self.view addSubview:self.pageView];


param.wEventClickSet(^(id  _Nullable anyID, NSInteger index) {
    NSLog(@"%@ %ld",self.pageView.upSc.currentVC,self.pageView.upSc.currentTitleIndex);
});


/// autoFix为NO 自己调整frame

// WMZPageView *pageView = [[WMZPageView alloc]initWithFrame:CGRectMake(0, 0, PageVCWidth, PageVCHeight - PageVCNavBarHeight) autoFix:NO param:param parentReponder:self]; // [self.view addSubview:pageView]; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = @"自定义视图";
    cell.detailTextLabel.text = @"自定义cell";
    return cell;
    }
  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
    }
  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
    }

//注释这段代码会出现 滚动冲突

  • (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.pageView performSelector:@selector(scrollViewDidScroll:) withObject:scrollView];
    }

`

没看出什么 是什么问题

@Lpkiki
Copy link
Author

Lpkiki commented Jan 24, 2024

就是 不在VC 里写上
(void)scrollViewDidScroll:(UIScrollView *)scrollView{
[self.pageView performSelector:@selector(scrollViewDidScroll:) withObject:scrollView];
}
这段代码,
view内的tableview 滚动 会 带着 vc 里的tableview 一起滚动

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants