0

右側のメニューで使用していますが、そのメニューが表示されている (または表示される予定の) トラックUITableViewの機能が見つかりません。RESideMenu

私は2つの機能を見つけました:

- (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController

- (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController

しかし、彼らは私が必要とすることをしません。メニューが開いたときにテーブルビューを更新するにはどうすればよいですか?
私のコード:
RightMenuViewController.h

#import <UIKit/UIKit.h>
#import "DataAPI.h"
#import "RESideMenu.h"
#import "RightMenuTableViewCell.h"

@interface RightMenuViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, RESideMenuDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

RightMenuViewController.m

#import "RightMenuViewController.h"

@interface RightMenuViewController ()

@end

@implementation RightMenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:[[[UICustomization sharedInstance].backgroundColour objectForKey:@"r"] floatValue]/225.0f green:[[[UICustomization sharedInstance].backgroundColour objectForKey:@"g"] floatValue]/225.0f blue:[[[UICustomization sharedInstance].backgroundColour objectForKey:@"b"] floatValue]/225.0f alpha:1.0f];

    _tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];

    if ([[UICustomization sharedInstance].tableBackgroundColour count])
        _tableView.backgroundColor = [UIColor colorWithRed:[[[UICustomization sharedInstance].tableBackgroundColour objectForKey:@"r"] floatValue]/225.0f green:[[[UICustomization sharedInstance].tableBackgroundColour objectForKey:@"g"] floatValue]/225.0f blue:[[[UICustomization sharedInstance].tableBackgroundColour objectForKey:@"b"] floatValue]/225.0f alpha:1.0f];
    else
        _tableView.backgroundColor = [UIColor clearColor];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:YES];
    NSLog(@"push notifications: %@", [DataAPI sharedInstance].pushNotifications);
}

- (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController {
    [_tableView reloadData];
    NSLog(@"push notifications: %@", [DataAPI sharedInstance].pushNotifications);
}

- (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController {
        [_tableView reloadData];
    NSLog(@"push notifications: %@", [DataAPI sharedInstance].pushNotifications);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if (![[DataAPI sharedInstance].pushNotifications count])
        return 1;
    else
        return [[[DataAPI sharedInstance].pushNotifications objectForKey:@"data"] count];

    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([[DataAPI sharedInstance].pushNotifications count]) {
        [DataAPI sharedInstance].orderNavButtonsOn = YES;
        [[ConnectionService instance]get_single_order:[UserAuth instance].username password:[UserAuth instance].password orderID:[[[[DataAPI sharedInstance].pushNotifications objectForKey:@"data"] objectAtIndex:indexPath.section] objectForKey:@"objectID"]];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(receiveConnectionData:)
                                                     name:@"SingleOrderDataReceived"
                                                   object:nil];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10.;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [[UIView alloc] init];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (![[DataAPI sharedInstance].pushNotifications count]) {
        static NSString *MyIdentifier = @"Identifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

        if (cell == nil)
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];

        cell.layer.borderWidth = 1.0f;
        cell.layer.borderColor = [UIColor colorWithRed:[[[UICustomization sharedInstance].cellBorderColour objectForKey:@"r"] floatValue]/225.0f green:[[[UICustomization sharedInstance].cellBorderColour objectForKey:@"g"] floatValue]/225.0f blue:[[[UICustomization sharedInstance].cellBorderColour objectForKey:@"b"] floatValue]/225.0f alpha:1.0f].CGColor;

        cell.textLabel.text = NSLocalizedString(@"no_notifications", nil);
        cell.textLabel.textColor = [UIColor colorWithRed:[[[UICustomization sharedInstance].primaryTextColour objectForKey:@"r"] floatValue]/225.0f green:[[[UICustomization sharedInstance].primaryTextColour objectForKey:@"g"] floatValue]/225.0f blue:[[[UICustomization sharedInstance].primaryTextColour objectForKey:@"b"] floatValue]/225.0f alpha:1.0f];

        cell.userInteractionEnabled = NO;

        return cell;
    } else {
        static NSString *MyIdentifier = @"rightMenuCell";
        RightMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

        if (cell == nil)
            cell = [[RightMenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];

        cell.dateLabel.text = [[[[DataAPI sharedInstance].pushNotifications objectForKey:@"data"] objectAtIndex:indexPath.section] objectForKey:@"date_time"];
        cell.timeLabel.text = [[[[DataAPI sharedInstance].pushNotifications objectForKey:@"data"] objectAtIndex:indexPath.section] objectForKey:@"ago"];
        cell.statusLabel.text = [[[[DataAPI sharedInstance].pushNotifications objectForKey:@"data"] objectAtIndex:indexPath.section] objectForKey:@"pushed_message"];

        return cell;
    }

    return 0;
}

- (void)receiveConnectionData:(NSNotification *) notification {
    if ([[notification name] isEqualToString:@"SingleOrderDataReceived"]) {
        [DataAPI sharedInstance].singleOrder = notification.object;
        dispatch_sync(dispatch_get_main_queue(), ^{
            [self goToViewWithIdentifier:@"toOrder"];
        });
    }
}

- (void)goToViewWithIdentifier:(NSString *)identifier {
    [self connectionCheck];
    [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[self.storyboard instantiateViewControllerWithIdentifier:identifier]]
                                                 animated:YES];
    [self.sideMenuViewController hideMenuViewController];
}

- (void)connectionCheck {
    if ([[ConnectionService instance]checkConnectivity] == NO) {
        UIAlertController * alert = [UIAlertController
                                     alertControllerWithTitle:NSLocalizedString(@"internet_connection_error_title", nil)
                                     message:NSLocalizedString(@"internet_connection_error_message", nil)
                                     preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction* quitButton = [UIAlertAction
                                     actionWithTitle:NSLocalizedString(@"internet_connection_error_cancel_button", nil)
                                     style:UIAlertActionStyleDefault
                                     handler:^(UIAlertAction * action)
                                     {
                                         exit(0);
                                     }];

        UIAlertAction* tryAgainButton = [UIAlertAction
                                         actionWithTitle:NSLocalizedString(@"internet_connection_error_try_again_button", nil)
                                         style:UIAlertActionStyleDefault
                                         handler:^(UIAlertAction * action)
                                         {
                                             [self connectionCheck];
                                         }];

        [alert addAction:quitButton];
        [alert addAction:tryAgainButton];

        [self presentViewController:alert animated:YES completion:nil];
    }
}

@end
4

2 に答える 2

0

DEMOLeftMenuViewController をチェックインして、テーブルビューを更新してください。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 54;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:21];
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor = [UIColor lightGrayColor];
        cell.selectedBackgroundView = [[UIView alloc] init];
    }

    NSArray *titles = @[@"Home", @"Calendar", @"Profile", @"Settings", @"Log Out"];
    NSArray *images = @[@"IconHome", @"IconCalendar", @"IconProfile", @"IconSettings", @"IconEmpty"];
    cell.textLabel.text = titles[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];

    return cell;
}

//デリゲート//

- (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController
{
[reload tableview];

}
于 2016-04-05T11:45:58.727 に答える