zoukankan      html  css  js  c++  java
  • iOS popViewControllerAnimated后刷新原先的表格

    当主页面列表push子页面,子页面修改后pop回主页面后应该刷新主页面列表数据,不修改子页面信息就不刷新主页面列表,这里介绍个取巧的方法:利用[NSNotificationCenter defaultCenter]两个页面传递消息

    主页面定义消息:

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(LuShuaXinTips:) name:@"LuShuaXinTips" object:nil];
    //子页面的消息,实现子页面操作后刷新列表
    -(void)LuShuaXinTips:(NSNotification*)nofi
    {
        if ([[nofi.userInfo objectForKey:@"shuaxin"] intValue]==1) {
            [self postSelfData];
            [self postSecondData];
        }
    }

    子页面:

    定义一个标志位,如果更改就刷新主页面列表数据,否则就不进行操作

    @property(copy,nonatomic)NSString* shuxinIndex;//刷新上一个界面的标志,如果是1就刷新

    子页面进行了操作,更改标志位

    self.shuxinIndex=@"1";

    子页面销毁后,发送消息,避免子页面冲突:

    -(void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:YES];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"LuShuaXinTips" object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:self.shuxinIndex,@"shuaxin", nil]];
    }
  • 相关阅读:
    静态内存不能跨函数使用
    多级指针
    数组大小的动态分配
    luoguP1629 邮递员送信
    luoguP1119 灾后重建
    luoguP1395 会议
    树的重心
    luoguP5536 【XR-3】核心城市
    树的直径
    luoguP5836 [USACO19DEC]Milk Visits S
  • 原文地址:https://www.cnblogs.com/luerniu/p/4723385.html
Copyright © 2011-2022 走看看