Cocoa User-Resizable Views - objective-c

how can i achieve user-resizable views like in interface builder, so that the user can adjust some images by their own
Do i have to manage all this manually with a view that watches mouse movement and so on?

You have to do all the work yourself. You will need to keep track of the objects in your view, their positions and do all the mouse tracking and view updating.
However, this is not actually very difficult, and Apple has provided a very complete example in its Sketch sample code.

I suggest drawing some buttons where you want the view to be resizable. Then start tracking mouse events in the view. Now, when a user drags its mouse while clicking on when of your spots, just change the view's frame accordingly. All of that should be possible to implement in a subclass of NSView.

Related

How to forward pointer events

I was able to get this working in iOS but I am having trouble with Win 8. What I need to do is this:
I have a drawing view that is the forward most child of a ScrollViewer. When I enable drawing mode from a button in the app bar, this view becomes active. With one touch, I want the user to be able to perform the current drawing action, but with two touches I want the touches to go to the scroll view instead for scrolling and zooming. I am able to distinguish between 1 and 2 (or more) fingers, but I don't know what to do after that point.
I tried removing the manipulation mode from the drawing view so that it would not block the scroll view, but the touches continued to be swallowed by the drawing view. I also tried calling ReleasePointerCapture but that had no effect either. How can I forward touch events using the WinRT API?
For some more information, I am making use of the PointerPressed, PointerChanged, etc events in the drawing view.

UIPanGestureRecognizer with UIPageViewController

I am using a UIPageViewController to display certain content. I want to be able to display additional content when the user pulls down on the page using a UIPanGestureRecognizer. I can't seem to figure out what I should add my gesture recognizer to such that it does not cancel any of the pageviewcontroller's actions.
One of the apps I worked on has functionality similar to this. It shows a full-screen UIPageViewController, but if the user drags down on a ribbon on the top right corner, it will slide the whole thing down to reveal a view behind (for settings and other stuff).
I think your problem is that the built-in gesture recognizers are for the page turns. So what you'd want to do is either have something to drag on (such as the ribbon on the top left in my app) that will have its own gestures. OR you can iterate through the gesture recognizers that are assigned to UIPageViewController and get the one that matches the PanGesture, then override it with your own functionality to either delegate the event to the UIPageViewController or do the slide down, based on the type of pan.
Hope that helps.

Full screen app with NSToolbar

This is hard for me to explain, so please bear with me for a minute.
In Xcode, if it is in full screen mode, showing the app's menu also moves the toolbar down. I have tried to make an NSView move and resize whenever the menu bar is shown, but I cannot figure out how to do it. I think this has something to do with and event, because setting struts and springs in Xcode does not make it move automatically. Can anybody help me figure out what the event is?
Edit: I just re-thought my question, and I have to make a correction. NSToolbar does this on it's own. I want a normal NSView to move and resize itself when the window goes into full screen mode.
I think you might be having the same issue as I was - if so, you need to call [NSToolbar setFullScreenAccessoryView:] on the "accessory view" you want to glue to the bottom of the NSToolbar.
Note that in windowed mode, your accessory view should take up space in the NSWindow's contentView just like any other view, but when you enter fullscreen mode you'll want to remove the accessory view somehow since Cocoa rips it out of your layout and leaves a gap unless you account for that.
I can certainly understand this issue being difficult to explain without having the background knowledge - I had the same problem. :)
Also see: How can I get a two-row toolbar like in Mail.app and Xcode?

Could the view to be pushed up when the keyboard occur?

I have created some textfields at the bottom that required users to entry. Is there any method that can push up the view automatically when the keyboard occur?
See Apple's Moving Content That Is Located Under the Keyboard, or this implementation based in Calculating Area Covered by Keyboard.
Basically you have to mount your view on a UIScrollView and add a bottom content inset with the same height than the keyboard. Then scroll using setContentOffset:animated:. This is a generic solution that you can reuse.
A more simple but non generic way is, if you have enough space at the bottom of your view without editable controls, you just scroll to a fixed position for each edit box.
use the -contentoffset property of your view.

Laggy UIScrollView

At the moment I'm working on an iPad explore game which has a hexagon tile map.
I've created a UIScrollView that contains a background view (the game map) and buttons in the form of hexagons (for interaction). I add every UIButton to the view via addSubview.
But... when I add more than 100 buttons the view gets laggy (no surprise here). But what should I do to solve this?
Example:
scroll view http://img233.imageshack.us/img233/5527/screenshot2011090110353.png
Adding UIButtons isn't the way to go here. You should probably draw the "buttons" in a custom -drawRect: method and use -touchesEnded:withEvent: to decide what the user wanted to do.