开发者

Why are some delegate methods not called automatically?

Why are some delegate methods not called automatically? I thought that if you used a delegate method that it would be called automatically. But That's not the case a开发者_如何转开发s I've found out. For an example see this post


In the case you mentioned, the method didUpdateHeading isn't called because the manager itself hasn't started yet. Basically, your controller is already listening for notifications, but the notifications don't even exist yet because the location manager hasn't been started. As soon as the manager is instructed to begin tracking user location, then the delegate methods will be called.

So in your example, you placed the startUpdatingHeading call inside the method that would be called once your manager is started. So, it never gets called.


To have a delegate method called, you need a delegate. And as the answer to that post said, the code was setting up the delegate inside a delegate method. So, if the delegate is set up inside a method that only runs after the delegate exist, nothing will happen.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜