Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I have a modal view controller, whom I'll call Bob. Bob is presented by Amy, who is Bob's delegate. When the user is done using Bob, Bob calls a method that is defined in Bob's delegate protocol. Amy responds by dismissing Bob.

There is a piece of code that is supposed to be run after Amy's parent view loads. It runs well when Amy is loaded into the navigation controller's stack, but not when Bob calls the aforementioned delegate method. If the code is in viewDidAppear, Bob won't even go away.

I did not knowingly cause this behavior, and I am not using any relevant third-party code.
 
Last edited:
Your second paragraph makes no sense to me.

When another view controller causes Amy to be displayed, the code in Amy's viewDidLoad method is executed. That does not happen when Bob is dismissed.
I moved the code to Amy's viewDidAppear method. After that, I ran the app. Bob didn't even disappear.

Here's the code that defines how Amy responds:

Code:
-(void)bobDelegateMethod
{
// Irrelevant code
    [self dismissViewControllerAnimated:false completion:nil];
}
 
OK, it looks like the view did appear for a very short amount of time before Bob reappears. However, this is not the behavior I expect. I think I can fix my app.

----------

Problem solved (sort of).

Edit: For some reason, the delegate method gets called multiple times. I don't know why.
Edit #2: it must be because Bob registered Amy to listen for an AVPlayerItem notification. I changed that.
 
Last edited:
Describing code is not a great way to get help with debugging. Please provide actual code. Because what you describe in English as the flow may not be what the code is actually doing. There may be some "loss in translation". If you're wary to provide code from your real project (due to privacy concerns, perhaps), build a test project that reproduces the issue. Provide that code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.