简体   繁体   English

重新加载UIView

[英]Reload a UIView

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 . 当我转到另一个视图并将另一个对象写入文件并返回到第一个视图时,对象应从文件中按原样加载到数组中,但不会以某种方式重新加载... [myTableView reloadData]不起作用, setNeedsDisplay都没有。

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

    NSLog(@"NOW IN VIEW WILL APPEAR");
    for(Contact *cn in contactsToLayNow)
    {
        NSLog(@"%@", cn.fName);
    }
    //[self.view setNeedsDisplay];

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


}

Move your [super viewWillAppear:animated]; 移动您的[super viewWillAppear:animated]; to first line of viewWillAppear: method. 到第一行viewWillAppear:方法。

you will need to retain contactsToLayNow - I guess it's being autoreleased sometime during your tableViews's drawing :) 您将需要保留contactsToLayNow-我想它是在tableViews的绘图过程中的某个时间自动释放的:)

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

PS It's not required but you should put your call to super at the top of this method ;) PS这不是必需的,但是您应该将对super的调用放在此方法的顶部;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM