zoukankan      html  css  js  c++  java
  • 美团HD(9)-监听点击城市

    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";
  • 相关阅读:
    将node.js代码放到阿里云上,并启动提供外部接口供其访问
    Linux内核深度解析之内核互斥技术——读写信号量
    man 1 2 3 4...
    Android Sepolicy 相关工具
    selinux misc
    ext4 mount options
    tune2fs cmd(ext fs)
    /dev/tty node
    kernel misc
    fork & vfork
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6403400.html
Copyright © 2011-2022 走看看