开发者

Reload a UIView

开发者 https://www.devze.com 2023-03-23 16:10 出处:网络
I have a view, when it starts, the array of objects is read from memory and the Table View is completed with the objects. When I go to another view and write another objects to file and get back to th

I have a view, when it starts, the array of objects is read from memory and the Table View is completed with the objects. When I go to another view and write another objects to file and get back to the first view, the objects are loaded into the array from file as it should but the doesn't reload somehow... [myTableView reloadData] doesn't work, neither does setNeedsDisplay.

-(void)viewWillAppear:(BOOL)animated
{
    contactsToLayNow=[NSKeyedUnarchiver unarchiveObjectWithFile:fPath()];

    NSLog(@"NOW IN VIEW WILL APPEAR");
    for(Co开发者_如何学Cntact *cn in contactsToLayNow)
    {
        NSLog(@"%@", cn.fName);
    }
    //[self.view setNeedsDisplay];

    [quickDialTableView reloadData]; //MOREOVER EXCEPTION HERE IS THROWN 
    [super viewWillAppear:YES];


}


you will need to retain contactsToLayNow - I guess it's being autoreleased sometime during your tableViews's drawing :)

contactsToLayNow = [[NSKeyedUnarchiver unarchiveObjectWithFile:fPath()] retain];

PS It's not required but you should put your call to super at the top of this method ;)


Move your [super viewWillAppear:animated]; to first line of viewWillAppear: method.

0

精彩评论

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