質問

hello to everyone ... In my app I have included a view that contains all the data of the current PFUser. Everything is done without Storyboard directly from code on ios7 ... THE display is no problem but when I perform I make logout and then log in again with another user different from the previous one, I did not update the information. The view continues to maintain that user's data to the one with whom I have come later.

Where 'my mistake?

Thanks to all of Rory

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self FFCustomViewGraph];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];


}
-(void)viewDidAppear:(BOOL)animated {
    self.navigationController.navigationBarHidden=NO;
}



-(void)FFCustomViewGraph {

    if ([PFUser currentUser] != nil) {
        PFQuery *query = [PFUser query];
        [query whereKey:@"Nome_Cognome" equalTo:[PFUser currentUser]];
        [query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {


            UIView *FFProfileView = [[UIView alloc] initWithFrame:CGRectMake(4, 68, 312, 123)];
            [FFProfileView setBackgroundColor:[UIColor colorWithRed:(237/255.0) green:(237/255.0)  blue:(237/255.0)  alpha:(1)]];
            [FFProfileView.layer setMasksToBounds:YES];
            [FFProfileView.layer setCornerRadius:3];
            [self.view addSubview:FFProfileView];



            PFImageView *FFImageProfile = [[PFImageView alloc] initWithFrame:CGRectMake(104, 136, 105, 105)];
            FFImageProfile.image = [UIImage imageNamed:@"FFIMG_Camera"];
            FFImageProfile.file = (PFFile *)[[PFUser currentUser] objectForKey:@"foto"]; // remote image
            [FFImageProfile.layer setMasksToBounds:YES];
            [FFImageProfile.layer setCornerRadius:52.0f];
            [FFImageProfile loadInBackground];
            [self.view addSubview:FFImageProfile];


            UILabel *FFNomeUsername = [[UILabel alloc] initWithFrame:CGRectMake(4, 59, 312, 70)];
            [FFNomeUsername setFont:[UIFont systemFontOfSize:18]];
            [FFNomeUsername setTextAlignment:NSTextAlignmentCenter];
            [FFNomeUsername setText:@"Massimiliano De Pascale"];
            [FFNomeUsername setTextColor:[UIColor colorWithRed:(158/255.0) green:(158/255.0) blue:(158/255.0) alpha:(1)]];
            FFNomeUsername.text = [[PFUser currentUser] objectForKey:@"Nome_Cognome"];
            [self.view addSubview:FFNomeUsername];

        }];
    } else {

    }








}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)FFLogout:(id)sender {
[PFUser logOut];
[self performSegueWithIdentifier:@"Login" sender:self];

}
@end
役に立ちましたか?

解決

I think I have solved! ... the problem was that:

[self FFCustomViewGraph] was inserted inside viewDidLoad ...

I solved it by moving it in viewDidLoad

 - (void) viewDidAppear: (BOOL) animated

Now the data is retrieved as soon as I log with another user ...

Do you think it is right or is it just luck?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top