您的位置:首页 > 移动开发 > IOS开发

iOS 在自定义tabbar上显示购物车的数量

2017-06-28 11:52 417 查看
//通过通知获取值

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {

    // Override point for customization after application launch.

    

    self.window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];

    self.window.backgroundColor
= [UIColorwhiteColor];

    [self.windowmakeKeyAndVisible];

    

    [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(getShopCarNumberActio
4000
n:)name:@"getShopCarNumber"object:nil];

    

    returnYES;

}

#pragma mark - 获取购物车的值

-(void)getShopCarNumberAction:(NSNotification *)noti

{

    NSDictionary * dic = [notiuserInfo];

    //self.numberLabel为在tabber上显示购物车数量的UILabel

    self.numberLabel.text = [dicobjectForKey:@"shopCarNumber"];

}

#pragma mark - 加入购物车的点击按钮事件

-(void)buttonAction

{

    [[NSNotificationCenter defaultCenter]postNotificationName:@"getShopCarNumber" object:nil userInfo:@{@"shopCarNumber":@"45"}];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: