ImagePicker slow with large photos - performance

I apologize i don't have any code to show for this problem. But i hope i can explain it well enough.
What should happend.
Users Taps a Button:
Image Picker is displayed. (present modal view)
User Chooses a photo:
the image picker dismisses (animated)
the chosen image is then loaded into a global object ( singleton)
and the chosen image is loaded into a IBOutlet UIImageView. in the current view.
A new view controller is pushed (animated ) which displays the image much larger.
For the most part this happens fine, however if a large photo, such as a photo taken by the iPhone 4 camera is loaded. the application lags and it jumps to the pushed view with no animations for the picker dismisal and the pushed viewcontroller.
is there a way to handle this better so the animations are shown?
performing certain task in the background with a selector?
Many thanks for your help.
Tom.

My only solution was to resize my image before pushing the next view controller!

Related

macOS, changing the size of a view controller by dragging

The user clicks a button and I present a new viewController as show.
Inside that VC there is a AVPlayerView, the same size as the VC.
The app itself can change size if the user drags any of its corners but the VC displaying the movie cannot.
Why things like that that should work by default, don't work as expected? What can be done to make this work?
Example:
This is the main app.
I can drag its corners and make it bigger or small. I can click on the green semaphore and make it full screen and it works fine.
When I press the Help icon, this "window" appears. It is a viewController that was added the story board.
This cannot be scaled. It "appears" to be a window, because it contains a semaphore. I cannot scale this but I can make it full screen by the green semaphore.
Note: I have added the view to a WindowController and now when the user presses the Help button this window controller is launched and the video appears. No change. Video cannot be scaled.
Found the problem.
I had to add a window controller controlling that View Controller.
View controller was not resizing even after #1.
Then I found that I could not have
self.preferredContentSize = CGSize(width: 940,height: 504)
inside awakeFromNib.
Now it works perfectly.
"The app itself can change size" –– what you're saying is that the window can be resized by the user.
"but the VC displaying the movie cannot" –– Again in this case, you're not trying to resize a view controller, you're trying to resize a window. The window contains your view controller.
The reason the window can't be resized is probably due to the layout constaints. I imagine there must be constraints somewhere in the view hierarchy which specifies that the video player (or some other view) has a specific width and height. Because it's a constant value, the window can't resize.

Xcode 6 Manual UIView Resize Issue

Ok, so I have multiple views on one of my screens. UIButtons, UIImageViews, UIViews, and a Container View.
Anytime I go to resize a view, it seems that one view will be auto resized to 0. When I resize via the actual inspector, no issues. It is just manual resizing on the storyboard itself.
I am not sure what is going on, has anyone experienced this?
>Check a video here<
Thanks in advance.

XCode Change Image From PopOver Navigation

I'm wondering if you can help me.
Basically we have a set of 16 images,
ImageA.png
ImageB.png ect ect...
That need to be shown by selecting it from a "Menu".
I want it to work like a split view controller, but I don't want to limit the width of the screen by having the navigation bar at the side, as the app must run in Landscape mode.
Here is the screenshots of what I have come up with instead of the SplitView;
http://i.stack.imgur.com/fdy21.png
The image is in a UIImageView,
And I have added a PopOver to the button that is linked to the UITableView.
What I want, is to be able to select an image from the PopOver Navigation, and it will change the image in the UIImageView to the corresponding.
Sorry if I haven't explained myself enough... I'm new to XCode!
Also: I am using XCode in Storyboard mode;
http://i.stack.imgur.com/RSuyY.png
Thanks,
Alex
To make the master view not be static on the side, implement this method in your UISplitViewControllerDelegate:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
return YES from this method, and the split view controller will behave the same way in landscape as it does in portrait

UIScrollView zooming and GUI management

I would like to programmatically allow the user to zoom away from a current page inside of UIScrollView and present them with an overview of multiple pages. Then allow them to touch/choose one of the pages to zoom in.
I have multiple sub ViewControllers for each page. The important aspect is that each ViewController contains detailed information, so I want most of that information to be visible when they get a "birds eye view" of what's happening.
What's the best way to do this?
Additional detail: pretend each UIViewController has a UiTableView within them. There's 5,6,3,1,0,10 Cells in each of these (respectively) is there a way to show all Cells at once in the larger view?
Perhaps is there a way to screenshot the Views and present them as smaller objects?
Currently I have the UIPinchGestureRecognizer already working, just need a way to control the transition of these viewcontroller into the middle. Is there a way to screenshot each controller and transition to a different view for selection?
If You want it for a pdf viewer, then maybe you can implement something similar to this:
https://github.com/vfr/Reader
When corresponding button is pressed - modally rises up a gridview with smaller pages. When taped on any - it then opens that page.
If it's not about pdf viewer, and You still desire the pinch-zoom effect, then maybe you can implement two different views - where - on one will be in grid - all viewcontroller thumbnails, and on other - scrollview. When you pinch -zoom out - scrollview alpha changes to 0, while gridview list alpha changes to 1. When taped on any viewcontroller thumbnail - alpha changes.
If You still want without fade-in fade-out, then it's even harder. On each pinch zoom movement, you need to recalculate each viewcontroller positions and sizes. and start moving them where they should be.
Hope that helps.. somehow..

Resize animations on a scrollview

I am trying to create a resize toggle animation on this simple custom TUIScrollView class (from TwUI open source project and very similar to UIScrollView) that I have built. It is called TUILayout and supports horizontal layout as well as vertical, animated insertions and removals and has a more declarative way of supplying data to it's cells that I prefer over delegation. It recycles views similar to TUITableView or UITableView. Anyway if you want to follow along, it's just one class and is here.
https://github.com/mrjjwright/TUILayout.
In the example code, the user clicks the blue button in the lower left and all the rows shrink smoothly to a size where the user can reorder and delete some rows (right click on a row in the example to see this in action), etc... and then the user toggle the rows back out to their original size by clicking the blue button again.
While doing this resize in setObjectHeight:animated I first resize my model objects that represent the rows, recalculate and set the contentSize on the TUIScrollView, cycle in all the new views (say 10 more views will fit in the shrunk view so dequeueReusableView and addSubview gets called 10 times) and finally I animate the frames of all the views to their size and location in layoutSubviews.
The result is that the scrollview correctly shrinks to a size where the scrollbar no longer displays, the views that are on screen animate smoothly down to their reduced size, but the newly added subviews that can now fit in the visibleRect animate in much later as one block of subviews.
So all the newly added subviews lag behind the views that were on the screen and I can't figure out why the animation isn't all happening together. I have tried lots of different combos of things with no luck including CATransactions. I am wondering if it has to with how a CAScrollLayer works or if somebody can help me think through this.
The more general issue is how to smoothly handle resizing animations on scrollviews that recycles their views and I have looked at several other grids out there in the iOS world and have got some inspiration but am looking for more.
Thanks!
I think I might have solved my own issue here (as I was making my bed this morning it hit me). I forced the current runloop to run after cycling in all the necessary subviews and very importantly not setting the contentSize of the scrollview until after the run loop completes and adds the needed subviews for the animation. In order to get the run loop to fire I used the trick from this SO question:
skipLayout = YES;
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate date]];
skipLayout = NO;
If skipLayout is set TUILayout just returns from layoutSubviews so that the views just added are not immediately removed by the recycling layout code. Forcing the run loop to run made sure that all subviews were on the screen for the animation. After this I performed the resize animated layout. I updated the code on github if anybody is interested. I will leave this question open for a while to gain some further insight.

Resources