How to link objects animations in Objective C? - ios

I'll make this as simple as I can.
I have a UIView in the shape of a balloon that floats around its original center. I want to add a line (to look as the rope) and I want it to be linked with its animation, as it turns out, drawing a line isn't as simple as adding a UIView, and the UIview doesn't include the line in it, it's a View Controller containing both.
How can I link both of them so that when the Balloon animates to a different position, the line end that touches the balloon animates with it?

Looks like the only way I could find around this was through NSNotification Center.

Related

Drawing a "pointer triangle" in swift

I have a UIStackView consisting of clickable images. Whenever I tap one of them, a UIView appears on the right side of the stack, showing some more info about the clicked object. I'm trying to make a triangle, that will show user to what line in the stack does the UIView relate to, like shown in the picture:
I don't know how to do that though. My solution would be probably just make 10 UIImageViews (there's 10 lines in the stack) and whenever user taps an image,set it's corresponding UIImageView to a triangle and the rest to nil. That's clunky and dirty, though, is there any better solution? I'm sure there lots of ways to accomplish that, but what's the best one?

Swift: Change label text value as animation plays

I've followed this answer to create an animated circle, and it works just fine. In addition to the path, I draw a text in the center of the view with drawInRect. I would like that text to change during the animation, to reflect the percentage of the path that is visible at each moment. How can I achieve that?
Thanks.
The most promising post would likely be this one. It describes creating a new CALayer that keeps track of the progress, which can then fire a call back.
Otherwise you'll likely need to wangle something together by observing your view's presentationLayer.

The better object view to a sudoku squares?

I'm developing a sudoku game in Objective C, in fact I kinda already finish it, I just have to adjust something of design and make a window view, somethings like that. But i'm still learning about iOS, so a I don't know what object view is the better to use in this case.
I'm using buttons to make the sudoku squares, but I wanna put in my game the possibility to make notes on the top of the squares with the possibilites that are available in that square, but the button view only have title propriety...
What view should I use instead of buttons?
Make a custom UIView subclass and initialize it with a UILabel on top and a UIButton covering all of it.

Dragging an uiview like facebooks menu slide

I know this has been probably asked before but I've seen many approaches and i don't know which is best for me, so plz don't send me a link to another post unless it addresses my problem directly.
I have a controller which has a uiview on the top (like a header) (this header is bigger than it seems because is partially hidden on top). on that view i have a uibutton which now with a touch up inside shows the entire header view and taping again returns it to its starting position (changing frame with animation). I want to also be able to drag the view but only changing position on the y axis(dragging up and down)... i was thinking of adding the dragInside/Outside event to the button but this doesn't give me the position of the finger... and also want to know when the user releases the drag so the view ends animation to any of its two possible states (showing or partially hidden). Is this a "touches began" , "touches moved" , "touches ended" thing? if it is please provide a code example. I also want to do this with another view but this is on the left side... same thing but this one moves on the X axis... any help is appreciated. or maybe it can be made with drag event if i only can save a CGpoint of last touch, maybe that's better, any other suggestions
Look at using a UIPanGestureRecognizer to detect the touch movements. Use the translationInView: of the gesture to set the view y position. The translation is the total movement since the start of the gesture so you don't need to remember and accumulate the offset position yourself.
The main thing to worry about while implementing this is bounding the y position of the view so that no matter how far the user drags the view won't go too high or low on the screen.
Use a UIPanGestureRecognizer, that's a class dedicated to handling such drag/pan gestures.
Everything is described here in Apple's documentation, including examples, so you should find your answer here.
There is also some sample code in Apple Developer Library that shows you how to use Gesture Recognizers if needed.

Animated move of UIPopoverController?

So, I have a setup where an UIPopoverController presents information at the cursor in a text view. When the cursor moves, I present it again. But this is jarring, and I'd like for the popover to move in a smooth, animated fashion. Will I really have to do that manually by using a series of presentFromRect calls, or is there a better way?
Unfortunately UIPopovers are not designed to be moved around like that.
The only way to do that without presenting it all over again is to write your own UIPopover replacement and animate its position using the standard CAAnimation or UIKit animation techniques.
If think you cannot do that without use presentFromRect. But if you really want to do this, create your own. Recreate the look of a popover controller using a UIView and track the touches. You can use an alternative like WEPopover.

Resources