Open xiu619544553 opened 4 years ago
- (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这种方式欠妥。
【Xcode 11.4.1 (11E503a) 】【iPad 12.4.7】【WMPageController 2.3.0】
关键的代码片段 / 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]; };
其他任何你觉得有可能帮助的信息; 使用 -reloadData 不存在 #2 中描述的问题