我正在为 iOS 6 的数据管理系统开发应用程序。这是我的代码:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationItem.title = @"Detail";
if (self.student.thumbnailImage != nil) {
[self.imageButton setImage:[UIImage imageWithData:self.student.thumbnailImage] forState:UIControlStateNormal];
} else {
[self.imageButton setImage:[UIImage imageNamed:@"Default_photo3.png"] forState:UIControlStateNormal];
}
NSLog(@"Student First = %@", self.student.firstname);
self.firstNameTF.text = self.student.firstname;
NSLog(@"Student Last = %@", self.student.lastname);
self.lastNameTF.text = self.student.lastname;
NSLog(@"Student IC = %@", self.student.ic);
self.icTF.text = self.student.ic;
NSLog(@"Student Form = %@", self.student.form);
self.formTF.text = self.student.form;
NSLog(@"Student Gender = %@", self.student.gender);
self.genderTF.text = self.student.gender;
NSLog(@"Student Birthday = %@", self.student.birthday);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
NSString *date = [dateFormatter stringFromDate:self.student.birthday];
self.birthdateTF.text = date;;
self.dateButton.titleLabel.text =date;
NSLog(@"Address = %@", self.student.address.street);
NSLog(@"Zip = %@", self.student.address.zip);
NSLog(@"City = %@", self.student.address.city);
NSLog(@"State = %@", self.student.address.state);
[self updateImageButton];
//Create a mutable array for guardians
NSSortDescriptor *sortDEscriptors = [[NSSortDescriptor alloc]initWithKey:@"firstname" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDEscriptors, nil];
NSMutableArray *sortedGuardians = [[NSMutableArray alloc] initWithArray:[self.student.guardians allObjects]];
[sortedGuardians sortUsingDescriptors:sortDescriptors];
self.guardiansArray= sortedGuardians;
[self.tableView reloadData];
}
我发现我的表格视图一开始没有滚动。但是当我删除[self.tableView reloadData]
这部分中的时,它确实滚动正常。有谁知道为什么?我需要把它放在[self.tableView reloadData]
这里,以便在编辑后更新数据。