0

I am fairly new to Xcode but not new to programming.

I am using XCode 4.6.1 using Storyboard creating an App to run on an iPad.

I am not familiar with NIBs ,only Storyboard.

My MainViewController needs two functional areas -

  1. A graph that is refreshed from a timer 10 times per second simulating readings from a monitor.
  2. Below this there are buttons / text boxes etc. to alter parameters that control the output to the graph.

I am trying to get the timer to trigger the refreshing of the graph. I have tried adding an imageView (both in Storyboard and in code) to no avail.

I cannot find a way to implement this ,I found one method using the old style NIBs. This uses the View's 'owner' instance, but Storyboard does not use the View's 'owner' .

Is there something peculiar about a viewController that will not allow this output to be shown (in the viewController) ?

Apparently I need to extend my viewController with a UIView and then implement the function drawRect to redraw the graph by using setNeedDisplay.

Could anyone tell me how to do this?

Many thanks.

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135

1 Answers1

0

you should 'never' try to call drawRect yourself. It should only be called by the OS at the right time. It sets up a GraphicsContext to draw in and also figures out what rect to draw and which other overlapping views need drawing!

call setNeedsDisplay instead! :)


so. e.g.

- (void) refreshTimerDidFire {
    [viewToRefresh setNeedsDisplay];
}
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • the ViewController's view is `viewController.view` but you should only refresh the view that really changes -- not everything – Daij-Djan Mar 30 '13 at 10:27