码迷,mamicode.com
首页 > 其他好文 > 详细

美团HD(9)-监听点击城市

时间:2017-02-15 22:06:16      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:ble   idc   监听   gen   import   mis   const   显示   cat   

 

DJSelectCityViewController.h

// 点击城市发出通知
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // 1. 发送点击的城市名
    DJCityGroup *cityGroup = self.cityGroups[indexPath.section];
    [[NSNotificationCenter defaultCenter] postNotificationName:DJCityDidChangeNotification object:nil userInfo:@{DJSelectCityName:cityGroup.cities[indexPath.row]}];

    // 2. 关闭当前controller
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

DJHomeViewController.m

/** 监听到城市改变广播 */
- (void)onReceiveCityChangeNotification:(NSNotification *)notification {

    NSString *selectedCityName = notification.userInfo[DJSelectCityName];
    
    // 1. 更新当前显示地区
    DJNavItem *areaView = self.areaItem.customView;
    [areaView setTitle:[NSString stringWithFormat:@"%@ - 全部",selectedCityName]];
    
}

DJConstantValue.m

#import <Foundation/Foundation.h>


/* 通知 */
NSString *const DJCityDidChangeNotification = @"DJCityDidChangeNotification";
NSString *const DJSelectCityName = @"DJSelectCityName";

 

美团HD(9)-监听点击城市

标签:ble   idc   监听   gen   import   mis   const   显示   cat   

原文地址:http://www.cnblogs.com/yongdaimi/p/6403400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!