开发者

how to use reload data in table view while working with two view?

I have two classes. In my first class i have table view which contains list of countries. And in my second view i have a picker which contain sorting by name. And i have button in my first class. On this button click i go on second class. In second class when i click on picker like sorting by name then the picker value store into NSMutableString. So i want that when i go back to my first view i want to show list according to 开发者_如何转开发the second class picker value. I use table reload in the viewWillAppear method of first view but its not working. Sometimes it crashes.

 -(void)viewWillAppear:(BOOL)animated
    {

        if(secondClassObj.isActStrPicker>=0)
        {

            sortByResultStr=[[NSString alloc]init];
            sortByResultStr=[secondClassObj  pickerValueStr];
            NSLog(@"picker class value of sorting  string fetech %@ if part sssssss",sortByResultStr);
        }
        else
        {
            //the else part is not working
            NSLog(@"picker class value fetech %@ else part sssssss",[cmpnyPickCheckObj isActStrPicker]);

        }
        [countrytableView reloadData];
    }

And i want that table shows value according to isActStrPicker(string) when i come back on this first view. Thanks for helping me


Try Call NSNotificationCenter

You can reload the tableView when you are not in that VIEW;

1. First In FirstVC.m, register a NSNotificationCenter, like this

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(reloadtableview) 
                                             name:@"ReloadTableView"
                                           object:nil]; 

-(void)reloadtableview {

//reload tableview

}

2*.Call this method to ask them to reload tableview:*

[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadTableView" object:nil];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜