0

新的一天新的问题我猜。

我正在使用带有 5 个按钮的 JASidePanel,每个按钮都会更改变量的值。该变量在 MyTableController.m 中用作 parseClassName。

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom the table

        // The className to query on
        if (_sDay==Nil) {
            self.parseClassName = @"Montag";
        }else{
        self.parseClassName = self.sDay;
        }
        // The key of the PFObject to display in the label of the default cell style
        self.textKey = @"Fach";

        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;

        // Whether the built-in pagination is enabled
        self.paginationEnabled = NO;

        // The number of objects to show per page
        self.objectsPerPage = 5;
    }
    return self;
}




- (void)viewDidLoad {
    [super viewDidLoad];

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hintergrund"]];
    imageView .frame = CGRectMake(0,0,255,458);
    [self.view addSubview:imageView];


    CGRect frameBtn = CGRectMake(0.0f, 0.0f, 254.0f, 50.0f);
    self.bMonday = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bMonday setBackgroundImage:[UIImage imageNamed:@"button_rechts_1"] forState:UIControlStateNormal];
    [self.bMonday setTitle:@"Montag" forState:UIControlStateNormal];
    [self.bMonday setFrame:frameBtn];
    [self.bMonday addTarget:self
                     action:@selector(monday:)
                 forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.bMonday];



    CGRect frameBtn2 = CGRectMake(0.0f, 50.0f, 254.0f, 50.0f);
    self.bTuesday  = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bTuesday setBackgroundImage:[UIImage imageNamed:@"button_rechts_1"] forState:UIControlStateNormal];
    [self.bTuesday setTitle:@"Dienstag" forState:UIControlStateNormal];
    [self.bTuesday setFrame:frameBtn2];
    [self.bTuesday addTarget:self
                      action:@selector(tuesday:)
           forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.bTuesday];


    CGRect frameBtn3 = CGRectMake(0.0f, 100.0f, 254.0f, 50.0f);
    self.bWendsday = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bWendsday setBackgroundImage:[UIImage imageNamed:@"button_rechts_1"] forState:UIControlStateNormal];
    [self.bWendsday setTitle:@"Mittwoch" forState:UIControlStateNormal];
    [self.bWendsday setFrame:frameBtn3];
    [self.bWendsday addTarget:self
                       action:@selector(wendsday:)
           forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.bWendsday];


    CGRect frameBtn4 = CGRectMake(0.0f, 150.0f, 254.0f, 50.0f);
    self.bThursday = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bThursday setBackgroundImage:[UIImage imageNamed:@"button_rechts_1"] forState:UIControlStateNormal];
    [self.bThursday setTitle:@"Donnerstag" forState:UIControlStateNormal];
    [self.bThursday setFrame:frameBtn4];
    [self.bThursday addTarget:self
                       action:@selector(thursday:)
           forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.bThursday];


    CGRect frameBtn5 = CGRectMake(0.0f, 200.0f, 254.0f, 50.0f);
    self.bFriday = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bFriday setBackgroundImage:[UIImage imageNamed:@"button_rechts_1"] forState:UIControlStateNormal];
    [self.bFriday setTitle:@"Freitag" forState:UIControlStateNormal];
    [self.bFriday setFrame:frameBtn5];
    [self.bFriday addTarget:self
                     action:@selector(friday:)
           forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.bFriday];






}

-(void)monday:(id)sender {

    UINavigationController *navController = (UINavigationController*) self.sidePanelController.centerPanel;

    MyTableController *myNewTableController = (MyTableController*)[navController.viewControllers objectAtIndex:0];
    myNewTableController.sDay = @"Montag";
    NSLog(@"%@",myNewTableController.sDay);

}

-(void)tuesday:(id)sender {

    UINavigationController *navController = (UINavigationController*) self.sidePanelController.centerPanel;

    MyTableController *myNewTableController = (MyTableController*)[navController.viewControllers objectAtIndex:0];
    myNewTableController.sDay = @"Dienstag";
    NSLog(@"%@",myNewTableController.sDay);


}
-(void)wendsday:(id)sender {

    UINavigationController *navController = (UINavigationController*) self.sidePanelController.centerPanel;

    MyTableController *myNewTableController = (MyTableController*)[navController.viewControllers objectAtIndex:0];
    myNewTableController.sDay = @"Mittwoch";
    NSLog(@"%@",myNewTableController.sDay);


}
-(void)thursday:(id)sender {

    UINavigationController *navController = (UINavigationController*) self.sidePanelController.centerPanel;

    MyTableController *myNewTableController = (MyTableController*)[navController.viewControllers objectAtIndex:0];
    myNewTableController.sDay = @"Donnerstag";
    NSLog(@"%@",myNewTableController.sDay);


}
-(void)friday:(id)sender {

    UINavigationController *navController = (UINavigationController*) self.sidePanelController.centerPanel;

    MyTableController *myNewTableController = (MyTableController*)[navController.viewControllers objectAtIndex:0];
    myNewTableController.sDay = @"Freitag";
    NSLog(@"%@",myNewTableController.sDay);


}

现在的问题是 PFQueryUITableView 没有显示新 parseClass 的内容,有人知道为什么吗?提前非常感谢!

4

1 回答 1

0

在您的monday...friday方法中,您正在设置sDay但您没有更改存储在parseClassName. 您可以修复它的一种方法是将以下内容添加到您的每个方法中

myNewTableController.parseClassName = @"SOME VALUE";

另一种选择是自定义设置器,sDay以便它更新parseClassName代码如下所示

- (void)setSDay:(NSString *)sDay
{
    if (![_sDay isEqualToString:sDay]) {
        _sDay = sDay;
        self.parseClassName = sDay;
    }
}
于 2013-04-25T22:49:44.093 回答