开发者

Tap Detecting Window and Two View Controllers

开发者 https://www.devze.com 2023-02-23 05:59 出处:网络
I\'m rather new to iOS development and for my first real app I\'m using a TapDetectingWindow to detect touches on a UIWebView (exactly as detailed on http://mithin.in/2009/08/26/detecting-taps-and-eve

I'm rather new to iOS development and for my first real app I'm using a TapDetectingWindow to detect touches on a UIWebView (exactly as detailed on http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way).

I used it in one View Controller as suggested with a reference in the header file and the following in the implementation file;

- (void)viewDidLoad {
        [super viewDidLoad];
        mWindow = (TapDetectingWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0];
        mWindow.viewToObserve = igWeb;
        mWindow.controllerThatObserves = self;

- (void)userDidTapWebView:(NSArray *)tapPoint {


    }

It worked perfectly.

Now the problem is that I would like to use the TapDetectingWindow in a second View Controller.

I copied the same code from the first view control开发者_开发问答ler (only changing the name of the viewToObserve).

Now, when I run the app. The Tap Detecting window works fine in the first ViewController, then works fine when you go to the second View Controller but when you go back to the first view controller its broken until the view gets loaded again.

Please help.


try something like

          -(void)viewWillAppear:(BOOL)animated
            {
                  mWindow.viewToObserve = igWeb;
                  mWindow.controllerThatObserves = self;
              [super viewWillAppear:animated];
             }
0

精彩评论

暂无评论...
验证码 换一张
取 消