sangony
sangony

Reputation: 11696

Manipulate UI from AppDelegate

I am a newbie in all this as will be apparent really soon.

I am using the iOS: Application: Tabbed application template. I have placed a UIImageView in the first view and two standard rounded buttons. One button is attached to an action in the FirstView Controller which places a picture into the UIImageView. The second button is attached to an action in the AppDelegate which calls a method in the FirstViewController which in turn places a second picture into the UIImageView.

The AppDelegate method does not replace the picture. It doesn't crash… it just does not seem to do anything.

How can I manipulate the view in the First and Second View Controller from the AppDelegate?

@dasdom Well that's one issue explained. I've been reading the theory of MVC and trying to put it into practice now. Short version is I am trying to write a Battleship app for practice. Was planning on using the first screen to setup the game pieces, prefs, etc.. and use the second screen for actual game play.

I've created another class to use as my "brain center" but I ran into the same issue of not being able to manipulate anything on the screen for the first or second views. (That's why I tried the appDelegate).

That's my life story right now… can you throw some pointers my way on how to proceed and how to solve my one of many problems?

Upvotes: 0

Views: 176

Answers (1)

dasdom
dasdom

Reputation: 14073

First you shouldn't do that. The AppDelegate should only be responsible for bringing the first view onto the screen.

Second you should have a look into the Model-View-Controller design pattern. Search for it in your preferred search machine.

But I you really still want to do that you should have a look into delegation and/or notifications. For example you could send the First View Controller a notification from the AppDelegate to change the image.

Upvotes: 1

Related Questions