_observer = [[NSNotificationCenter defaultCenter] addObserverForName:YZUpdateMenuTitleNote object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
NSInteger col = [self.controllers indexOfObject:note.object];
if(col != NSNotFound) // <-
{
// 获取对应按钮
UIButton *btn = self.menuButtons[col];
// 隐藏下拉菜单
[self dismiss];
// 获取所有值
NSArray *allValues = note.userInfo.allValues;
// 不需要设置标题,字典个数大于1,或者有数组
if (allValues.count > 1 || [allValues.firstObject isKindOfClass:[NSArray class]]) return ;
// 设置按钮标题
[btn setTitle:allValues.firstObject forState:UIControlStateNormal];
}
网友评论