0

I've got this really weird bug on my code, and I have no idea on how to solve it.

I'm using the stroryboard scheme as shown on the picture attached. One navigation controller, that performs a push segue programatically, and, when clicking the "Find" button, the "findsegue" is supposed to be performed.

So, the problem is: Randomly, the view is not loaded. viewDidLoad is executed, but nothing changes on my screen. Some other times, it all works like a charm.

Here is the code that is called when the "Find" button is pressed:

- (IBAction)encontreBtn:(id)sender {
  NSLog(@"Segue is going on");
  [self performSegueWithIdentifier:@"findsegue" sender:sender];
}

@"Segue is going on" is always printed. And that's the viewDidLoad:

- (void)viewDidLoad
{
  [super viewDidLoad];
  NSLog(@"DIDLOAD");
    // Do any additional setup after loading the view.
  _topBar.font = [UIFont fontWithName:@"LibelSuit-Regular" size:23];
  _topBar.textAlignment = NSTextAlignmentCenter;
  _tableView.dataSource = self;
  _tableView.delegate = self; 
}

@"DIDLOAD" does print as well. As a note, viewDidAppears runs as well.enter image description here

Arthur Camara
  • 578
  • 8
  • 19
  • Does `DIDLOAD` print every time? If `DIDLOAD` prints, the stuff in `viewDidLoad` should have been executed. With that said, `viewDidLoad` doesn't get called every time the view appears. – nhgrif Dec 19 '13 at 02:32
  • Yup. DIDLOAD does print everytime. After pressing the "Find" button, the segue is fired, "Segue is Going On" print, as well as "DIDLOAD". – Arthur Camara Dec 19 '13 at 03:08
  • And what on your screen do you expect to change? There's nothing in your `viewDidLoad` that would be different from one load of the screen to the next as far as I can tell, nothing really dynamic... – nhgrif Dec 19 '13 at 03:25
  • Well, the next scene. (The Encontre View Controller scene) The controller that is shown after I click "Find" is the same as "View Controller Home". – Arthur Camara Dec 19 '13 at 03:30
  • When I click "Find", sometimes the next scene is loaded, sometimes it's not. `viewDidLoad` does run, as well as viewDidAppear. But the screen does not change. If I restart the simulator one or two times, the next scene does appear as it should. – Arthur Camara Dec 19 '13 at 03:32
  • When you say "sometimes", what does that mean exactly? Does it load the first time every time? – nhgrif Dec 19 '13 at 03:39
  • It's completely random. If it does work on the first try, it will keep working until I close the simulator. If it doesn't work, it won't work until I close the simulator. – Arthur Camara Dec 19 '13 at 03:43
  • When it doesn't work, is `viewDidLoad` being called? – nhgrif Dec 19 '13 at 03:44
  • Yes. viewDidLoad is being called, even if it does not work. – Arthur Camara Dec 19 '13 at 03:45
  • And the program doesn't crash? It just doesn't load? – nhgrif Dec 19 '13 at 03:45
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43471/discussion-between-arthur-camara-and-nhgrif) – Arthur Camara Dec 19 '13 at 03:46
  • Does "findsegue" specifically connect the Find button to the next view controller or does it generally connect the one view controller to the next? – Lyndsey Scott Dec 19 '13 at 04:32
  • @Lyndsey, that's general. The segue is connecting the ViewControllers, not the button itself. – Arthur Camara Dec 19 '13 at 11:00

0 Answers0