سؤال

Could somebody explain me what i'm doing wrong in the code below? I try to pass data from the didSelectRowAtIndexPath method but in the SizeViewController productKey has still value of null

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

                [tableView deselectRowAtIndexPath:indexPath animated:YES];
                SizeViewController *sizeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SizeView"];
                sizeViewController.title = [self.choosedProducts objectAtIndex:indexPath.row];
                sizeViewController.productKey  = [self.choosedProductsIds objectAtIndex:indexPath.row];
                [[self navigationController]pushViewController:sizeViewController animated:YES];

}

هل كانت مفيدة؟

المحلول

Can u try to get a reference to the storyboard instead of using the self.storyboard property? It is just a guess.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

Also, can u verify in your solution that sizeViewController is not nil?

نصائح أخرى

You are trying to load a view controller from storyboard,So it should be initialised as

SizeViewController* detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SizeViewController storyboard identifier"];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top