prepareForSegue does not display any action on the button

0

I am relatively new to these schedules and have come across an issue that goes beyond me completely. So I have a menu with 6 UIButtons set to IBOutlet in my viewcontroller. Each of these UIButtons call a specific html internally housed in the Xcode project. The issue is that when using the prepareForStart function xcode by and simply ignores any action on the buttons.

This is my prepareForSegue function:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (sender == self.Secretaria){
    uptPiso1WebViewController *vc = (uptPiso1WebViewController*)segue.destinationViewController;
    vc.url=[NSURL URLWithString:[NSURLRequest requestWithURL:[NSURL URLWithString:@"Piso1/Secretaria/vtour/tour.html"]]];

} else if (sender == self.sala){
    uptPiso1WebViewController *vc = (uptPiso1WebViewController*)segue.destinationViewController;
    vc.url=[NSURL URLWithString:[NSURLRequest requestWithURL:[NSURL URLWithString:@"Piso1/Sala105/vtour/tour.html"]]]; 
}
}

Once again, I am referring to my inexperience and I apologize if my question may be too vague, but my last resort was to try to find a solution here.

Greetings

    
asked by anonymous 11.06.2014 / 17:49

1 answer

1

I created a project to try to simulate what happens to yours, I did not have the problems you encountered, however I noticed that when you associate the value with vc.url , I imagine that this property is NSURL , you create correctly an NSURL from a String, but instead of passing a String, you are passing an NSURLRequest with another URL, this crashes in the app by NSInvalidArgumentException .

Try to use only:

vc.url = [NSURL URLWithString:@"Piso1/Secretaria/vtour/tour.html"];

And then, in class uptPiso1WebViewController call the following method in webview:

NSURLRequest *request = [NSURLRequest requestWithURL:_url];
[_webview loadRequest:request];

2 other points to improve the code:

  • Do not compare objects with == as you did with the buttons. Use [sender isEqual:self.Secretaria] link

  • Learn how to use link

  • Download the project: link

        
    13.06.2014 / 22:55