I’m trying to acces the storyboard from code to be able to use this line:
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
I use that in my mapview and listview, but want to use it somewhere else to.
The problem is that this view, is a subview of another view.
It’s set up as followed:
thisBigView is a view I added in the storyboard and it’s is ThisBigViewController
In storyboard I added another view to that view, let’s call it thisSmallView. The class is set to ThisSmallView.
ThisSmallView is a custom view where I generate buttons dynamically in on the view. These buttons call the following action:
-(void) radarEventClick:(UIButton *)sender{
SingletonManager *sharedManager = [SingletonManager sharedManager];
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"]; // PROBLEM 1
Event *a;
for(int i = 0; i < [sharedManager.eventsManager count]; i++){
if(sender.tag == ((Event*)([sharedManager.eventsManager objectAtIndex:i])).id_nr){
a = [sharedManager.eventsManager objectAtIndex:i];
break;
}
}
[detail setEvent:a];
[self.navigationController pushViewController:detail animated:YES]; // PROBLEM 2
}
This is code I’m using in my mapviewcontroller to respond to annotationdisclosure clicks, and want to use it here to, but I have 2 problems!
PROBLEM 1: Because thisSmallView is a subview of anotherview, it doesn’t have direct access to the storyboard and don’t know how to get that access.
PROBLEM 2: thisBigView is embed in a navigationcontroller, but again, I don’t know who to access thisBigView, so I can’t access the navigationcontroller.
(I think if I could solve problem 2, I would automatically be solving problem 1 to?)
— EDIT: what I tried —
DetailViewController *detail = [self.superview.storyboard instantiateViewControllerWithIdentifier:@"detail"];
But then I just get ‘property storyboard not found on object of type UIView*’
Add the subview as a property of the superview in interface builder (control-drag to the header file). Then add a
UIViewControllerproperty to the subview. In the superview’s code then do