Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's why <code>viewDidLoad</code> gets called only the first time the view is loaded; to get you problem solved you have to defer those actions you're performing into that method to the <code>viewWillAppear</code> method. </p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated] if (startButton.hidden == NO){ [pauseButton setHidden:YES]; [continueButton setHidden:YES]; } else { [pauseButton setHidden:NO]; [continueButton setHidden:NO]; } } </code></pre> <p><strong>EDIT</strong></p> <p>Ok, your problem is due to the fact your <code>DetailViewController</code>s get deallocated each time they are pushed onto the top of the navigation stack, that's why you see the view they controls in the same state you get when you pushed it the first time. </p> <pre><code>// here the detail view controller gets allocated DetailViewController *dvc = [[DetailViewController alloc]init]; </code></pre> <p>I didn't understand the expected behavior of your task tracking system: in particular the way is determined when a given task can be considered as finished - i.e., the way your countdown logic works for each task( What's supposed to happen for example when you started a task and suddenly your app goes to background, the timer gets stopped then resumed as the app goes back to foreground?, etc. )</p> <p>Suppose you want that your timer resumes its state as you push back the same view you pushed few instants before, </p> <p>I suggest you to use a delegate (or block if you will), e.g. </p> <pre><code>- (void)timeElapsed:(NSTimeInterval)secondsElapsed forTask:(NSUInteger)task { //here you can save, e.g., in your task array the remaining seconds the task have to run // for example, supposing you're using a linear index to track down the position of the associated timer NSTimeInterval remainingSeconds = [self.taskArray[task] timeInterval] - secondsElapsed; [self.taskArray[task] setTimeInterval:remainingSeconds]; } </code></pre> <p>The table view controller should implements that method, and the DetailViewController should be initialized with an index relevant to the task associated to.</p> <p>You also should make the following changes to the DetailViewController in order to message the tableViewController the number of seconds consumed by a given task.</p> <pre><code>- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.timer invalidate]; self.timer = nil; // remember to check if the delegate actually performs that selector [delegate timeElapsed:secondsElapsed forTask:taskIndex]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload