I've created a basic graph with Core Plot.
The graph succesfully showed in the center of the view, only I would like to show the Graph in fullscreen. Where can I change the frame size of the Graph?
I hope someone can help. Many thanks!
The graph will always fill its hosting view. Since the hosting view is a subclass of UIView, you can position and size the same as you would any other view.
Related
Thanks to Apple's PictureSwiper sample code and the very nice NSPageController tutorial from juniperi here on stackoverflow, it's pretty easy to get tantalizing close to image viewing capabilities in Preview. Specifically I want to replicate the ability to swipe forwards/backwards between images/pages, use pinch-to-zoom resize the images, gesture to rotate the images/pages, and support two-page mode.
But there are some hurdles that make me wonder if NSPageController is the right approach or if it is too limiting and a custom view controller is needed.
1) Images of varying sizes are simply displayed stacked and if the top/upper layer image is smaller, the underlying image(s) show through. Using the same images in preview, they hide the larger "underlying" images/pages and fade the underlying image in/out with the swipe transition. I could hide underlying images by linking the page controller to the view rather than the image cell (like PictureSwiper), but that causes the entire view to scale on pinch to zoom and overall looks clunky.
2) Is it possible to use NSPageController with more than one image cell, e.g. two-page mode?
3) Is page/image rotation possible with NSPageController?
4) Is it possible to lock the zoom level for all the images, so they are uniformly displayed as navigated?
My apologies if this too general of a question, but the gist is whether NSPageController too limited and problematic to extend which would necessitate building a custom controller from scratch.
Thanks.
I have a UIImageView that is undergoing a simple translation animation, and I am trying to get the coordinates of the view while it is moving via the imageview.frame.origin.x property. However, it is giving me the coordinates that the imageview will be at after the animation. Is there any way to get the current coordinates?
Yes, you need to check the coordinates of the presenationLayer. You can read a detailed description about it in my blog post about tapping moving layers.
I'm developing an ipad application about 2d drawing.
I need a UIView.frame size of 4000x4000. But if I set a frame with size 4000x4000 the application
crash since i get memory warning.
Right night I'm using 1600*1000 frame size and the user can add new object (rectangle) on frame. User can also translate fram along x and y axis using pan gesture in order to see or add new object.
Have you got some suggestion? how can I tackle this problem?
thanks
Well, I would suggest what is used in video games for a long time - creating a tiled LOD mechanism, where only when you zoom in toward specific tiles, they are rendered at an increasing resolution, while when zoomed out, you only render lower resolution.
If the drawing in based on shapes (rectangles, points, lines, or anything can be represented by simple vector data) there is no reason to create a UIView for the entire size of the drawing. You just redraw the currently visible view as the user pans across the drawing using the stored vector data. There is no persistent bitmapped representation of the drawing.
If using bitmap data for drawing (i.e. a Photoshop type of app) then you'll likely need to use a mechanism that caches off-screen data into secondary storage and loads it back onto the screen as the user pans across it. In either case, the UIView only needs to be as big as the physical screen size.
Sorry I don't have any iOS code examples for any of this - take this as a high-level abstraction and work from there.
Sounds like you want to be using UIScrollView.
I'm trying to write a fairly simple animation using Core Animation to simulate a book cover being opened. The book cover is an image, and I'm applying the animations to its layer object.
As well as animating a rotation around the y axis (The the anchorPoint property set of the left of the screen), I need to scale the right hand edge of the image up so it appears to "get closer" to the user and create the illusion of depth. Flipboard, for example, does this scaling really well.
I can't find any way of scaling an image like this, so only one edge is scaled and the image ends up nonrectangular.
All help appreciated with this one!
CoreAnimation, by default, "flattens" its 3D hierarchy into a 2D world at z=0. This causes perspective and the like to not work properly. You need to host your layer in a CATransformLayer, which will render its sublayers as a true 3D layer hierarchy.
I'm trying to use a scatter plot from Core Plot in my iOS application. I set up Core Plot as the Core Plot wiki says, and then I copy PlotItem.h/m, PlotGallery.h/m and SimpleScatterPlot.h/m from the included Plot Gallery project into my project. The code
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
SimpleScatterPlot *scatterPlot = [[SimpleScatterPlot alloc]init];
[scatterPlot generateData];
[scatterPlot renderInLayer:hostView withTheme:theme];
runs, and the graph view is shown in my app. But I cannot move the graph view around or tap the plot points as in the Plot Gallery project. How do I set this up right?
The Plot Gallery is a poor starting point for a simple Core Plot demonstration. It has a lot of extra "stuff" to support generating a table view with thumbnails of all the different plots. The -renderInView:withTheme: method is used to make the thumbnail images for the table view. It renders the graph as an image which is why you lose interactivity. Unless you need the flexibility to quickly add new plots to your app and easily support both MacOS and iOS, I would recommend using one of the other examples as a starting point. The architecture is much simpler and easier to understand.
You need to have a CPTGraphHostingView in the visible view hierarchy. Set your graph as its hostedGraph. Look at any of the other example apps to see how to set up the hosting view. The graph setup and datasource code in the Plot Gallery plots (e.g., SimpleScatterPlot) is fine and should work anywhere.