2012-08-28 45 views
0

我想从另一个viewcontroller(我正在PSStackedViewExample https://github.com/steipete/PSStackedView工作)重新加载tableview。我的UIViewController在哪里做修改是有点在我的UITableViewController上,我正在对当前在我的TableView上的数据进行更改,这就是为什么我想重新加载tableview直接看到更改,当我修改UIViewController上的东西。如何从另一个UIViewController重新加载UITableViewController

我无法访问它...每当我发疯时,你能帮助我吗?

对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。我需要做一个reloadData上实现代码如下从以前的UITableViewController

#include "PSStackedViewDelegate.h" 
#import "AppDelegate.h" 

@interface ExampleViewController1 : UIViewController <PSStackedViewDelegate, UITextFieldDelegate> 
{ 
    IBOutlet UIButton *validateBtn; 
    IBOutlet UIButton *cancelBtn; 

    singleObjGetData *sObjDataForRootVC; 
} 

的.M

#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; 
} 

感谢很多的帮助...

+0

而不是添加的代码块(人们可以从链接代码),加上一些截图这将阐述什么其实你的问题是 –

+0

我现在无法访问ftp服务器,我不能对不起 – xGoPox

回答

0

您可以通过设置做到这一点第二个tableview中的通知在第一个tableview上调用reloadData。把这个在你的第二个的tableView:

[[NSNotificationCenter defaultCenter] 
postNotificationName:@"refreshData" 
object:nil 
userInfo:nil//userInfoDictionary 
]; 

在您第一次的tableView把这个:

[[NSNotificationCenter defaultCenter] 
addObserver:self 
selector:@selector(methodToRefreshYourFirstTable) 
name:@"refreshData" 
object:nil]; 
相关问题