我想从另一个视图控制器重新加载一个表格视图(我正在处理 PSStackedViewExample https://github.com/steipete/PSStackedView)。我进行修改的 UIViewController 在我的 UITableViewController 上有点,并且我正在对我的 TableView 上当前的数据进行更改,这就是为什么我想重新加载 tableview 以在我修改 UIViewController 上的某些内容时直接查看更改。
我无法访问它...每次我对此感到疯狂,你能帮帮我吗?
在 PSStackedViewExample 项目中,我说的 UITableViewController 是 ExampleViewController2。我正在谈论的 UIViewController 是:ExampleViewController1
这是一些代码,以防您不下载项目:
ExampleMenuRootController 是主控制器,它调用 UITableViewController
.h 首先 ->
#import <UIKit/UIKit.h>
#import "Guest.h"
@interface ExampleMenuRootController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
    UITableView *menuTable_;
    NSArray *cellContents_;
    singleObjGetData * sObjDataForRootVC;
    UIViewController *viewController;
}
@property (nonatomic, retain)  UIViewController *viewController;
@property (nonatomic,strong) NSManagedObjectContext* managedObjectContext;
- (void)checkDictionnaryForIndexPathForFunction;
-(IBAction)showTable:(id)sender;
- (void)checkDictionnaryForIndexPath:(NSString *)check;
@end
.m ->
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    PSStackedViewController *stackController = XAppDelegate.stackController;
     viewController = nil;
        [sObjDataForRootVC.tmpGuest removeAllObjects];
        [self checkDictionnaryForIndexPath:@"0"];
        [self checkDictionnaryForIndexPath:@"1"];
        [self checkDictionnaryForIndexPath:@"2"];
    if (indexPath.row > 0 && indexPath.row < 4)
    {
    [sObjDataForRootVC.tmpGuest removeAllObjects];
    [self checkDictionnaryForIndexPath:[NSString stringWithFormat:@"%i", indexPath.row - 1]];
    }
    if (indexPath.row > 3 && indexPath.row < 8)
    {
        [sObjDataForRootVC.tmpGuest removeAllObjects];
        [self checkDictionnaryForIndexPathForFunction];
    }
    while ([stackController.viewControllers count]) {
        [stackController popViewControllerAnimated:YES];
    }
// HERE I CALL THE UITABLEVIEWCONTROLLER !!!
    viewController = [[ExampleViewController2 alloc] initWithStyle:UITableViewStylePlain];     
    ((ExampleViewController2 *)viewController).indexNumber = [stackController.viewControllers count];
    if (viewController) {
        [XAppDelegate.stackController pushViewController:viewController fromViewController:nil animated:YES];
    }
}
然后在下面,UIViewController 的 .h 将修改 UITableView。我需要从以前的 UITableViewController 对 tableview 执行 reloadData
#include "PSStackedViewDelegate.h"
#import "AppDelegate.h"
@interface ExampleViewController1 : UIViewController <PSStackedViewDelegate, UITextFieldDelegate>
{
    IBOutlet UIButton *validateBtn;
    IBOutlet UIButton *cancelBtn;
    singleObjGetData *sObjDataForRootVC;
}
他们
#import "ExampleViewController1.h"
#import "ExampleViewController2.h"
#import "ExampleMenuRootController.h"
#import "PSStackedView.h"
@implementation ExampleViewController1
#pragma mark - View lifecycle
- (void)viewDidLoad {
    sObjDataForRootVC  = [singleObjGetData singleObj];
    confirmPressed = NO;
    [self setUpView];
    [super viewDidLoad];
    self.view.width = PSIsIpad() ? 400 : 150;
}
非常感谢您的帮助...