Почему UITableView не может быть reloadData - PullRequest
0 голосов
/ 19 октября 2011
 -(void) reload{
        [self.tableViewa reloadData];
    }

    -(void) viewWillAppear:(BOOL)animated{
        [self.tableViewa reloadData];
        [cachedProperties setTags:nil];


        self.tabBarController.navigationItem.rightBarButtonItem =nil;
        self.tabBarController.navigationItem.leftBarButtonItem =nil;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return [[cachedProperties getTags] count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CheckMarkCellIdentifier = @"CheckMarkCellIdentifier";
        UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CheckMarkCellIdentifier] autorelease];

        NSUInteger row = [indexPath row];

        if([[[cachedProperties getTags] objectAtIndex:row] isNotEmpty]){
            cell.textLabel.text = [[cachedProperties getTags]objectAtIndex:row];
            cell.accessoryType= UITableViewCellAccessoryDetailDisclosureButton;
        }
        return cell;
    }

с этим методом, когда viewWillAppear существует код [self.tableviewa reloadData] и будет вызывать numberOfRowsInSection, но когда я вызываю метод Reload, для которого есть [self.tableviewa reloadData], функция numberOfRowInSection вызываться не будет.. как это может быть?какая-либо причина этой проблемы?

, потому что в firstTime вызывается viewWillAppear, [cachedProperties setTags: nil] будет устанавливать теги и будет вызывать -(void) reload{ [self.tableViewa reloadData]; } или [thatClass.tableViewa reloadData], которые мне нужны, чтобы tableView не был нулевым.почему tableView не reloadData?

1 Ответ

0 голосов
/ 19 октября 2011

Попробуйте это:

 -(void) reload{
        [self.tableViewa reloadData];
        [cachedProperties setTags:nil];
    }

    -(void) viewWillAppear:(BOOL)animated{
        [self reload];

        self.tabBarController.navigationItem.rightBarButtonItem =nil;
        self.tabBarController.navigationItem.leftBarButtonItem =nil;
    }

...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...