大家好...在我的应用程序中,我已经包含了一个包含当前PFUser的所有数据的视图。一切都是在没有故事板的情况下直接从ios7上的代码完成...显示没有问题,但是当我执行注销然后再次使用与前一个不同的用户登录时,我没有更新信息。视图继续将用户的数据保存到我之后来的那个数据。
我的错误在哪里?
感谢所有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
答案 0 :(得分:0)
我想我已经解决了! ......问题在于:
[self FFCustomViewGraph]已插入viewDidLoad ...
我通过在viewDidLoad中移动它来解决它
- (void) viewDidAppear: (BOOL) animated
现在,当我与其他用户登录时,我们会立即检索数据......
你认为这是对的还是只是运气?