NSNumber *theTag = [NSNumber numberWithInt:btn.tag];
NSDictionary *tagInfo = [NSDictionary dictionaryWithObject:theTag forKey:@"theTag"];
// 设置通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"setView" object:nil userInfo:tagInfo];

// 接收通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(choosenBtn:) name:@"setView" object:nil];

/**
 *  通知触发方法
 */
- (void)choosenBtn: (NSNotification*) aNotification
{
    MLTabBarButton *btn = [[MLTabBarButton alloc] init];
    NSDictionary *tagInfo = aNotification.userInfo;
    NSString *a = [tagInfo objectForKey:@"theTag"];
    // 字符串转integer
    btn.tag = [a integerValue];
    [self btnOnClick:btn];
    [self setSelectIndex:btn.tag];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"setView" object:nil];
}

Dean
34 声望1 粉丝

哦也