我有一个导航视图控制器,它与UITableViewController
. 在表格视图控制器中,我有静态单元格。我有表格视图单元格的正确标签格式。UIViewController
单击时我将导航到,UITableViewCell
然后当我导航回我的 时UITableViewController
,我想更新我的UITableViewCell
.
我能够将值从enter code here
eUIViewController
传递到UITableViewcontroller
. 我已经使用NSLog
. 但我无法更新单元格中的详细信息标签。
我使用过-(void) tableView:(UITableView *) tableView didDeselectRowAtIndexPath
,但这对我没有帮助,因为只有当我单击另一个表格视图单元格时,表格视图单元格才会更新。我希望此更新在我导航回时自动发生UITableViewController
请查看以下链接 http://www.icodeblog.com/wp-content/uploads/2011/10/navigation_interface.jpeg
我想要类似上图的东西
如何才能做到这一点。
更新代码
@interface designTableViewController ()
@end
@implementation designTableViewController
{
glimmpseliteAppDelegate *appDelegate;
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
appDelegate = [[UIApplication sharedApplication]delegate];
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
-(void)viewWillAppear:(BOOL)animated
{
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 8;
}
#pragma mark - Table view delegate
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 1)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designSolvingForViewController"];
[self.navigationController pushViewController:uiViewController animated:YES];
tb.detailTextLabel.text = appDelegate.solvingFor;
}
if(indexPath.row == 2)
{
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designTypeIErrorRate"];
[self.navigationController pushViewController:uiViewController animated:YES];
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.typeIError;
}
if(indexPath.row == 3)
{
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designNumberOfGroups"];
[self.navigationController pushViewController:uiViewController animated:YES];
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.numberOfGroups;
}
if(indexPath.row == 4)
{
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designRelativeGroupSize"];
[self.navigationController pushViewController:uiViewController animated:YES];
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.relativeGroupSize;
}
if(indexPath.row == 5)
{
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designSmallestGroupSize"];
[self.navigationController pushViewController:uiViewController animated:YES];
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.smallestGroupSize;
}
if(indexPath.row == 6)
{
UIViewController *uiViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"designMeansAndVariance"];
[self.navigationController pushViewController:uiViewController animated:YES];
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.meansAndVariance;
}
}
- (void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 1)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
tb.detailTextLabel.text = appDelegate.solvingFor;
}
if(indexPath.row == 2)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
//tb.textLabel.text =@"Sample";
tb.detailTextLabel.text = appDelegate.typeIError;
}
if(indexPath.row == 3)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
//tb.textLabel.text =@"Sample";
tb.detailTextLabel.text = appDelegate.numberOfGroups;
}
if(indexPath.row == 4)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
//tb.textLabel.text =@"Sample";
tb.detailTextLabel.text = appDelegate.relativeGroupSize;
}
if(indexPath.row == 5)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
//tb.textLabel.text =@"Sample";
tb.detailTextLabel.text = appDelegate.smallestGroupSize;
}
if(indexPath.row == 6)
{
UITableViewCell *tb = [tableView cellForRowAtIndexPath:indexPath];
//tb.textLabel.text =@"Sample";
tb.detailTextLabel.text = appDelegate.meansAndVariance;
}
}
@end
第一个表格单元格只是一个有按钮的单元格。我有一个用于那个按钮的推送 UIViewController。