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]];
    }
  • 相关阅读:
    使用VSCode创建简单的Razor Webapp--1.入门
    ASP.NET Razor 常用示例
    ASP.NET Razor 语法
    ASP.NET Razor简介
    EF CodeFirst 一对一、一对多、多对多关系
    mysql外键
    EF CodeFirst 之 Fluent API
    替换JDK 对eclipse的影响?
    mysql数据库,安装 !创建!...详解!
    Apache的commons工具类
  • 原文地址:https://www.cnblogs.com/luerniu/p/4723385.html
Copyright © 2011-2022 走看看