I need to show a blue point (current user location) on my map. It's a trivial task, on my device with iOS7 it works ok, on another device with iOS6 it doesn't. I set map view's delegate from .xib, also my map is connected with controller through an outlet and I do not init/alloc this property in controller (I saw a lot of guys doing this). One more thing to notice is that regionDidChangeAnimated is called ok, and it's one of map view's delegate methods. I don't have idea why this happens.
There is a bug in IOS6, if you are added the mapView:viewForAnnotation: after setting the delegate, then this delegate method will not be invoked. MapView will be use a default annotation view in this case. So try to remove your delegate connection from outlet and set the connection after a cleaning.
Related
This has really been pissing me off for a while now, and I have no idea how to get further. I have created a tabbed application hence getting the default UITabBarController + 2 View controllers that are nested within this. Fair enough. Now I noticed the viewcontrollers viewDidLoad methods wasn't called when switching around. Ok, so I find theres a tabbar delegate for when a viewcontroller gets "tabbed." Now my problem is the delegate method which I've placed in AppDelegate, is not being called. I have tried in all ways I know of to make a reference to the given tabbarcontroller (to se the delegate programmatically) and I have tried ctrl-dragging the delegate to anywhere possible. Am I doing sth wrong? (because everywhere I look this seems to not be a problem, and people are holding reference to their tabbars).
Thanks
I used this code to get a reference to the tabbar, so I could set the delegate programmatically:
UITabBarController *tabBar = ((UITabBarController*)self.window.rootViewController).delegate = self;
Very simple, I guess I was running late night hours yesterday.
Yet the issue was clearly using storyboard and then trying to make an outlet in app delegate (I still dont think that is possible).
You have to set your view controller's class in storyboard if you want to be able to make references. Select your view controller in storyboard. On the right panel go to Identity inspector and in the Class field set the name of the class. The you should be able to make references and also viewDidLoad should be called.
I wanted to override the function scrollViewDidEndScrollingAnimation for a reference to a tableView within a class.
In other words, I have a view and a UITableView within it, I dragged a reference to the table into the view controller and want to change the scrollViewDidEndScrollingAnimation for the same, is it possible to do so?
I have looked at previous responses to similar questions and they ask suggest making the class a scrollViewDelegate and implementing the function, but I have done so and it doesn't hit the breakpoint I have within the function even if I scroll through the table in the Simulator.
This method only gets called if the setContentOffset:animated: or scrollRectToVisible:animated: methods are called by you on the scrollView, and only if the animated parameter is set to true.
Scrolling the view in the simulator will not trigger the breakpoint in your implementation, but using either of those two methods will.
UIScrollViewDelegate Protocol Reference
I have dragged out a splitViewController, and identified it as a subclass I have created MySplitViewController.
When Right-clicking the splitview storyboard I can see that I've set its Master and Detail view controllers, and furthermore that the delegate is NOT set.
I have made my subclass conform to the protocol and implemented some methods, but they are not being called (which I not understand is because the delegate is not set).
But whenever I try to ctrl+drag from the delegate option in the storyboard to my class, it won't link up. In fact, it won't link up with anything. Am I using this protocol wrong, should my subclass of UISplitViewController not be its own delegate? Then where do I define the delegate in code or otherwise?
Thank you for your time.
Edit: More info-
I tried putting self.delegate = self; in viewDidLoad, but that didn't seem to help.
The particular method I am trying to override is
splitViewControllerPreferredInterfaceOrientationForPresentation:
and I've put an NSLog in the code to notify me if it gets called, which it isn't
As far as I know, NSSplitViewControllers cannot have delegates, and their splitViews can't have their delegates reassigned since the controller acts as the delegate.
If you need access to the delegate methods, simply subclass the controller, then change the class name in Interface Builder.
I found some unexpected behavior when debugging one of my table views.
My tableView in the storyboard does not have its delegate or dataSource set.
However, at the breakpoint in this snippet, both are set to the view controller. I've checked my entire viewDidLoad hierarchy and at no point is the delegate set.
My question is: is this expected behavior? or is it a bug in Xcode or the SDK?
If your view Controller is a UITableViewController, then the delegate and data source of the table view it is the controller for is set to itself unless they are set in Interface Builder.
I have a tableview in a nib file, that has the datasource and delegate set to file's owner. It also has an outlet set to an IBOutlet property declared in the class. All of the datasource methods responds as one would expect. None of the delegate methods respond.
I have gone through everything I can think of so far: deleting the tableview, adding another, clicking and unclicking the datasource and delegate connections, you name it. Always the same.
I have a tap gesture recognizer on the main view, and the delegate set to self. So when a tap comes in, I'm able to intercept it in the gesture recognizer delegate method, and the tap is indeed coming from a table view cell. This is recognized as a tap from within the table, and so the method returns NO to tell the gesture recognizer not to respond.
Any thoughts?
Well, we tried everything. Shutting down Xcode, blowing the environment away and re-checking out the code, shutting down the machine, nothing.
Copied those files to another machine, and it works.
Clueless...