Draggable MapKit Annotations - mapkit

I am working with MapKit on MacOS and trying to enable a draggable annotation that uses a custom image. I can successfully get the annotation to be draggable but it requires the user to be quite accurate with where they click and drag as the annotation image is larger than a conventional pin. Is there a simple way to expand the area so that any part of the image is draggable? Otherwise I imagine I will have to use some kind of NSGesture on the view to manually set the dragstate, but was hoping there might be an easier way!

Okay, I never managed to sort this to my satisfaction using Annotations. I’m not saying it can’t be done, maybe someone else can comment and leave pointers to help. But I eventually achieved what I wanted using overlays instead. So if someone stumbles on this question and has the same issue, you can make it work with a custom overlay rather than an annotation and you implement the dragging using a NSPanGestureRecognizer with translation for the movement.

Related

Keyboard shortcut to move map view?

I'm trying to implement the same feature, that Maps.app has on OS X, where when selecting the map, the arrow keys on the keyboard moves the map north/south (up/down) and east/west (left/right).
I've created a sample project, added a MKMapView to the storyboard just to ensure that I've not overwritten anything in my 'real' project, but the default behavior is the same, ie. the map is not responding to the keyboad strokes.
I've searched the documentation, looking at the delegate protocols, but have been unable to finde an answer. Any ideas? (It does not matter if its Swift or Objective-C)
So, after a few days thought, I've come to this solution:
Create a function that moves the map (I've used setCenterCoordinate:), and trigger this from keyDown. There is a little regarding zooming and moving the map that need to be thought of though.
I'm leaving this here, in case someone can use it :)

Dynamically changing content of UIScrollView

I'm trying to create a menu for a local multi-player game that dynamically updates when peers become available on the network.
The interface I want to implement is a UIScrollView, where each page displays information about a peer. Ideally, these pages are added and removed when a peer's availability changes.
I have looked through several tutorials using UIScrollView, but they all seem to pull page information from a plist or pre-loaded array.
What I want must be possible; weather app behaves in a similar manner, dynamically adding or deleting location pages. I'm not sure where to turn for further help, though. How do I dynamically update my scroll view's contents as outside events occur?
I decided to go with UICollectionView instead, it seems to provide a better method of implementation for what I'm trying to accomplish. Thanks!
Have a look at this Ray Wenderlich Tutorial.
I've used it as a basis for doing a paged scroll and the mechanism is simple enough to extend to whatever dynamic scheme you would like.
You can check this site for Multiple Tutorials & examples for UIScrollview. The link:
is Here..
I am sure, you'll able to find some good code for your need. Hope it works for you.

I am trying to create a 2D tile map engine that works sort of like a tiled ScrollView

I already have a function that can return a tile for a given position. I am trying to make it so that when I scroll around it will load new tiles on the fly. I am having trouble figuring out how to attack the problem. I am sure that someone must have done this before and I would prefer to not reinvent the wheel on this.
Can anyone point me to a tutorial or some example code?
If not, can perhaps help me figure out how to do this?
I am using Kobold2D and the map is not going to be static, it will be generated on the fly, Minecraft style.
CATiledLayer is perfect for this. However, I do not know if this will play well with Cocos2d.

Cocoa + CoreAnimation: Animated List of Custom Subviews

I've been trying to get this right for weeks now, and though I've learned a lot through my misfires, at this point, I just need a solution. The issue is with unpacking the seemingly overlapping graphics and UI APIs included in Cocoa, many of which produce similar effects, but feature unique limitations that I've often discovered only after investing many hours into an implementation.
I'm new to Cocoa, but not to programming, and I'm trying to create a Mac app with a very customized UI – think Capo, Garageband, or Billings. One view in my window will display an ordered list of subviews, each of which does a lot of custom drawing, and each must support a "selected" state and drag-reordering. The subviews do not need to support being dragged outside of their superview.
Ideally, a drag will give animated feedback as it happens, pushing neighboring sibling views to make space, e.g. toolbar icons or the Safari bookmarks bar. The trouble is, I can't seem to land on the right pack of technologies to get this right. I've done the subviews as NSView subclasses in an NSCollectionView and also as CALayers in a custom CollectionView-like NSView, and neither seems to offer the perfect solution. That said, the first option seems the better of the two for its superior handling of mouse events.
I've not yet tried doing this as a TableView, and I don't want to go down that path without some indication I'm on the right track. Extensive Googling has shown only that there aren't any up-to-date resources on CoreAnimation-enabled reordering or dragging. As such a standard feature of the OS X UI, I feel like this should be easier!
Any help from anyone on what the right tools are for this job would be greatly appreciated. TIA.

Zoom-able/ resizable grid with Objective-C

Hi i'm thinking about making midi step sequencer and I need to make a note grid/matrix that resizes/ adapts when you zoom. I've been searching for different ways of doing this but cant figure out a way that works well.
I thought about drawing cell objects made with (NSRect) but I couldn't figure out how to get the right interaction when resizing.
This is my first "biggish" OBJ-c project so please don't kill me, im still battling with the frameworks and the syntax is so foreign to me.
You could use Core Animation layers to create your grid.
Take a look at Apple's Geek Game Board sample code project:
http://developer.apple.com/library/mac/#samplecode/GeekGameBoard/Introduction/Intro.html
The code shows a way to display different kinds of card/board games using CALayer.
The Checkers game looks to be the closest to the grid you want to create.