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

updateTitle:atIndex 存在的问题 #632

Open
xiu619544553 opened this issue Jun 5, 2020 · 1 comment
Open

updateTitle:atIndex 存在的问题 #632

xiu619544553 opened this issue Jun 5, 2020 · 1 comment

Comments

@xiu619544553
Copy link

  1. 【Xcode 11.4.1 (11E503a) 】【iPad 12.4.7】【WMPageController 2.3.0】

  2. 关键的代码片段
    /*
    vc是控制器数组的一个元素。
    当vc标题发生变化时,使用 -updateTitle:atIndex 函数,更新指定 index 的标题,存在一个问题:如果 新title.length > 旧title.length,则 MenuItem 标题部分内容显示省略号
    */
    vc.updateTitleBlock = ^(WXCouponTitleModel * _Nonnull titleModel) {
    StrongSelf
    [strongSelf.lists objectAtIndex:0].count = titleModel.count;
    [strongSelf updateTitle:@"xxx" atIndex:0];
    };

  3. 其他任何你觉得有可能帮助的信息;
    使用 -reloadData 不存在 提个问题 #2 中描述的问题

@Mr-yuwei
Copy link

Mr-yuwei commented Jun 12, 2020

解析问题

  1. update == NO值问题
- (void)updateTitle:(NSString *)title atIndex:(NSInteger)index andWidth:(BOOL)update {
    if (!update) { return; }
    [self resetFrames];
}

2.delegate或dataSource数据源没有更改

- (void)updateTitle:(NSString *)title atIndex:(NSInteger)index {
    [self.menuView updateTitle:title atIndex:index andWidth:NO];
}
看下这两个方法返回值
- (NSString *)pageController:(LMPageController *)pageController titleAtIndex:(NSInteger)index
- (CGFloat)menuView:(LMPageMenuView *)menu widthForItemAtIndex:(NSInteger)index 

建议步骤

1.修改

- (NSString *)pageController:(LMPageController *)pageController titleAtIndex:(NSInteger)index

2.修改

- (CGFloat)menuView:(LMPageMenuView *)menu widthForItemAtIndex:(NSInteger)index 

3.执行

self.tagArray[0] = @"目标值";
[self.menuView updateTitle:@"目标值" atIndex:0 andWidth:YES];

写在最后

这种写法只是把功能实现了,但是直接跨过WMPageController去操作menuView这种方式欠妥。

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