Question

The issue is, that I have been unable to get the UI Activity Indicator to activate animation or show when user selects cell from table view.

The execution cycle looks like this:

  • View loads with table view
  • User clicks cell - (UIActivityIndicator fails at this step to appear or animate)
  • Activity indicator appears while data is being gathered
  • New view is called with the loaded data
  • User clicks back button from the navigation bar
  • Repeat cycle

loading object is the activity indicator link from the storyboard.

@synthesize jsonConnection, bakeryProductArray, bakeryTableView, loading;

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    [self retrieveData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)viewWillAppear:(BOOL)animated
{

    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    loading.hidden = YES;
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}


#pragma mark - UITableView DataSource

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


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView) {
        return [searchResults count];
    }
    else {
    return [bakeryProductArray count];

    }
}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    }

    if (tableView == self.searchDisplayController.searchResultsTableView) {
        foodProducts *currentProduct = [searchResults objectAtIndex:indexPath.row];
        cell.textLabel.text = currentProduct.productName;
    }
    else {
    foodProducts *currentProduct = [bakeryProductArray objectAtIndex:indexPath.row];
    cell.textLabel.text = currentProduct.productName;
    cell.detailTextLabel.text = currentProduct.productquantity;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    return cell;

}

#pragma mark - UITableView Delegate methods

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (bakeryTableView == self.searchDisplayController.searchResultsTableView) {
        [self performSegueWithIdentifier: @"bakeryDetails" sender: self];
    }

        detailedViewController *productinfo = [self.storyboard instantiateViewControllerWithIdentifier:@"bakeryDetails"];
        //Retrieve current user array
        foodProducts *currentProduct2 = [bakeryProductArray objectAtIndex:indexPath.row];
        productinfo.productName = currentProduct2.productName;
        productinfo.productImage = currentProduct2.productImgUrl;
        productinfo.productDescription = currentProduct2.productDescription;
        productinfo.productPrice = currentProduct2.productPrice;
        productinfo.productQuantity = currentProduct2.productquantity;
        productinfo.productAllergy = currentProduct2.productAllergy;

        [loading startAnimating];

        [self.navigationController pushViewController:productinfo animated:YES];
        [bakeryTableView deselectRowAtIndexPath:indexPath animated:YES];

}

I have check obvious stuff like:

If the activity indicator is behind an object. Not activating features from the IB

If you need more info, just say.

Any help would be great guys

Cheers

Was it helpful?

Solution

Correct me if im wrong, but I can't find anywhere, where you have declared the activity indicator. Try adding this into your viewDidLoad, or where it starts animating

loading = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
loading.frame =//set frame
[self.view addSubview:loading];
//Or add it to the cell in didselectrow etc

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top