IIViewDeckController with left always showing on iPad - ios

I am using IIViewDeckController and I would like to always have the left side controller open and resize the center view so that the layout looks similar to UISplitViewController.
According to the docs:
It is possible to have the viewController always show a side
controller. You do this by setting the maxSize value to any (positive)
nonzero value. This will force the centerview to be always opened,
exposing a side controller permanently. This only works when you have
ONE sidecontroller specified (this means either a left side controller
or a right side controller), because this scenario does not make sense
if you would be able to slide the center view in both directions. When
you have 2 side controllers, this property is ignored.
I have done exactly what it says, but it will not always show the side controller:
PUCNews *news = [[PUCNews alloc] init];
UINavigationController *newsNav = [[UINavigationController alloc] initWithRootViewController:news];
[puc.cachedViewControllers setObject:newsNav forKey:#"news"];
PUCLeftNavigationViewController *leftNav = [[PUCLeftNavigationViewController alloc] init];
IIViewDeckController *deckController = [[IIViewDeckController alloc] initWithCenterViewController:newsNav leftViewController:leftNav];
deckController.openSlideAnimationDuration = 0.20f;
deckController.closeSlideAnimationDuration = 0.20;
deckController.centerhiddenInteractivity = IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose;
deckController.elastic = NO;
if ([Utility isIpad]) {
//deckController.leftSize = 200;
deckController.maxSize = 500;
//deckController.sizeMode = IIViewDeckLedgeSizeMode;
[deckController toggleLeftViewAnimated:NO];
deckController.centerhiddenInteractivity = IIViewDeckCenterHiddenUserInteractive;
deckController.resizesCenterView = YES;
deckController.panningMode = IIViewDeckNoPanning;
}
This also is causing some very strange rotation issues.
How can I always have the left side controller open and resize my center view so that it fits within the rest of the screen?

I've used this,
self.leftController = leftController;
self.leftSize = 700;
[self openLeftViewAnimated:NO];
this works for me because I want a small space in the left size. Probably you need to play with the size afterwards, but this works!
Hope it helps you.
Cheers

Related

Key-Frame Animation appears fuzzy when moving Frames?

I use JazzHands to create a key frame based animation in a UIScrollView.
Here is an example. Look at the view at the top. When you move from page to page. While the animation is running the view at the top is slightly moving from left to right. The animation appears a bit fuzzy.
Here is the code taken from the example here:
IFTTTFrameAnimation *titleView1FrameAnimation = [IFTTTFrameAnimation new];
titleView1FrameAnimation.view = self.titleView1;
[self.animator addAnimation:titleView1FrameAnimation];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(1)
andFrame:self.titleView1.frame]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(2)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(2), 0)]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(3)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(3), 0)]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(4)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(4), 0)]];
When running the demo take a look at the part marked with red in the following screenshot:
Edit: Here is the code containing this problem: https://github.com/steffimueller/Intro-Guide-View-for-Talk.ai
How can I make the animation running smooth and less fuzzy?
This is due to the frame rate in the JazzHands IFTTTAnimatedScrollViewController being set for non-retina displays. You need to double the number in timeForPage, and also use double the number of the contentOffset in animate, but use the original non-doubled values of timeForPage in places where you were using that for laying out the positions of views instead of using it for the animation time.
Here's a Gist of the changes you'd have to make to your example to get it working. Fixed Demo Gist
You need this method for setting the animation times:
#define timeForPage(page) (NSInteger)(self.view.frame.size.width * (page - 1) * 2.0)
And this one for setting the centers of your views based on the page dimensions:
#define centerForPage(page) (NSInteger)(self.view.frame.size.width * (page - 1))
Then you need to override the scrollViewDidScroll: method in IFTTTAnimatedScrollViewController to use double the numbers it's currently using.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.animator animate:(NSInteger)(scrollView.contentOffset.x * 2)];
}
We'll work on getting the JazzHands demo updated!
Before you start your animation call:
view.layer.shouldRasterize = YES; (seems that you are using objective-c so I put YES here, for swift should be true)
As soon as the animation is finished call
view.layer.shouldRasterize = NO; (seems that you are using objective-c so I put NO here, for swift should be false)
You should always use it when you animating a view
You can see more details about it in the WWDC 2012 Polishing Your Interface Rotations video (paid developer subscription needed)
I hope that helps you!
[EDIT]
Every Time you call the method animate set shouldRasterize to YES before it, like in the example bellow:
titleView1FrameAnimation.view.layer.shouldRasterize = YES;
[self. titleView1FrameAnimation animate:scrollView.contentOffset.x];
I've messed around a bit with the code and it seems that keeping those top views in place while the scrollview is scrolling made it jiggle left and right.
What I did is take out the title view from the scroll view and add it to the view controller view.
You can see it in action here
Later edit:
To actually see what I've changed you can check the file differences in Git. Basically I moved your titleViews (titleView1, titleView2, etc) from the scrollView to the view controller's view (so basically I've replaced all the lines that were like this:
[self.scrollView addSubView:self.titleView1]
to something like this:
[self.view addSubView:self.titleView1]
After that I've also took out the keyframe animations that were keeping your title views in place since they were not moving with the scrollview anymore. Practically I've deleted all the lines that were adding a frame animation to your titleviews from each configurePageXAnimation.
2nd question answer:
Say your screenshot view is called screenshotView. You can go ahead and create it like this:
UIImageView *screenshotView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"ScreenshotImage"]];
[self.view addSubview:screenshotView];
self.screenshotView = screenshotView;
[self.screenshotView setCenter:CGPointMake(self.view.center.x + self.view.bounds.size.width, <#yourDesiredY#>)];
And animate it like this:
//screenshotView frame animation
IFTTTFrameAnimation *screenshotViewFrameAnimation = [IFTTTFrameAnimation new];
screenshotViewFrameAnimation.view = self.screenshotView;
[self.animator screenshotViewFrameAnimation];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(1) andFrame:self.screenshotView.frame]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(2) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width, 0.0)]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(3) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width, 0.0)]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(4) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width * 2, 0.0)]];

iOS app UI has been pushed down due to Call Notification

Here is the scenario.
Before launching my app, I make a phone call. Then I open my app, the status bar height has doubled due to call notification. and because of that, the entire UI of my app has been pushed down by additional 20pt. Switching back to phone app and end the call, when I open my app again, the UI gets stuck as just now, except that the green notification bar's gone, leaving an additional 20pt black bar on top.
This does not happen if my app is already launched before I make the call.
I've used [self.window makeKeyAndVisible];
Any idea how to adjust UI properly in this case?
Update:
Here's the code
ADTransitionController *transitionController= [[ADTransitionController alloc] initWithRootViewController:[[MainViewController alloc] init]];
transitionController.wantsFullScreenLayout = YES;
ConfigurationSetupViewController *menuController = [[ConfigurationSetupViewController alloc] init];
REFrostedViewController *frostedViewController = [[REFrostedViewController alloc] initWithContentViewController:transitionController menuViewController:menuController];
frostedViewController.direction = REFrostedViewControllerDirectionLeft;
frostedViewController.liveBlurBackgroundStyle = REFrostedViewControllerLiveBackgroundStyleLight;
if ([GBDeviceInfo deviceDetails].majoriOSVersion < 7) {
frostedViewController.blurRadius = 2;
}
self.window.rootViewController = frostedViewController;
I've drilled down the problem with REFrostedViewController. If I set rootViewController to transitionController, the layout is perfectly aligned.
Update2:
So the fact is.. when a double status bar is present, ADTransitionController will set coordY = 20 and height = 548. REFrostedViewController does the same thing.. causing I have 40 margin on top.. One thing I'm not sure is.. when is the frame of these UIViews being set?

Moving Particle View to Front of Screen?

I currently have a particle view connected to storyboard. The problem that I'm facing is that I'm displaying an alert at the same time I show this view, and the alert is always shown in front of the particle view. Is there a way where I can always place the particle view in front? I'm using a third party alert library titled SIAlertView, so I'm assuming it may be possible.
I've logged the zPosition of the alertView and it's always 0, so I set the zPosition of my particle view's layer to 10, but it is still shown beneath the alert view.
Here's the storyboard hierarchy:
I do not know about SIAlertView but normal UIAlertView is shown via separate window. If you want to overlap it you can not do it by changing zpozition, you have to also use a separate window:
// do not forget to keep strong reference for it somewhere!
UIWindow *notificationWindow;
//your frame here!
notificationWindow = [[UIWindow alloc] initWithFrame: some_cgrect];
notificationWindow.backgroundColor = [UIColor clearColor]; // your color if needed
notificationWindow.userInteractionEnabled = NO; // if needed
// IMPORTANT PART!
notificationWindow.windowLevel = UIWindowLevelAlert + 1;
notificationWindow.rootViewController = [UIViewController new];
notificationWindow.hidden = NO; // This is also important!
UPDATE:
To overlap also a status bar use
notificationWindow.windowLevel = UIWindowLevelStatusBar;
to dismiss UIWindow just invalidate strong pointer to it. Something like:
self.strongPointerToYourWindow = nil;

How to set width and positon ModalDialog in the center before it loads?

I created a modal dialog in my viewController.
dialogViewController *dialog = [[dialogViewController alloc] init];
dialog.modalPresentationStyle = UIModalPresentationFormSheet;
dialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
dialog.indexPath = indexPath;
dialog.campaignArray = self.campaignArray;
dialog.view.superview.frame = CGRectMake(dialog.view.superview.frame.origin.x+250, dialog.view.superview.frame.origin.y, dialog.view.superview.frame.size.width-250, dialog.view.superview.frame.size.height);
[self presentViewController:dialog animated:YES completion:nil];
The above changes the width but not the x position of the modal dialog. It works in the modalDialog but then user can see it being resized.
If you want to use
UIModalPresentationFormSheet
the controller will be centred. There is very specific formatting included in this. If you want anything different, you will have to build your own.
The width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
Try this:
dialogViewController *dialog = [[dialogViewController alloc] init];
dialog.modalPresentationStyle = UIModalPresentationFormSheet;
dialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
dialog.indexPath = indexPath;
dialog.campaignArray = self.campaignArray;
[self presentViewController:dialog animated:YES completion:nil];
CGRect dlgFrame = dialog.view.superview.frame;
dlgFrame.size.width -= 250.0;
dialog.view.superview.frame = dlgFrame;

How to update iOS PhotoScroller sample code

I'm using altered sample code from PhotoScroller within my app. I have a table view of image thumbnails, and I can pass the array of images that populate that table to PhotoViewController. Currently, PhotoViewController starts with the first image in my array and I can scroll back and forth. This works properly as Apple's sample code.
Now What I want to do is tap a table cell with thumbnail, and start scrolling images beginning with the image in my array at that index. Ex: if I have 5 images in a table and I tap image #3, I want the first image in PhotoViewController to be that third image, and able to scroll left or right to #2 or #4. Hope this makes sense.
I see in PhotoViewController that sub views are being added per image. Any way I can tell it "jump to view #3" without destroying the other views or their overall order of appearance? Any ideas or advice is welcome. Code can be found on the iOS developer site for PhotoScroller sample code.
Ok, I'm rambling... Thanks in advance for your help!
The way I do this is to have a variable called startingPage which gets set in the initialiser of the photo view controller. Then when the pages are being created, first set the correct offset for the scroll view.
So in the PhotoScroller case that would be in loadView. Like so:
- (void)loadView
{
// Step 1: make the outer paging scroll view
CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor blackColor];
pagingScrollView.showsVerticalScrollIndicator = NO;
pagingScrollView.showsHorizontalScrollIndicator = NO;
pagingScrollView.contentSize = [self contentSizeForPagingScrollView];
pagingScrollView.delegate = self;
self.view = pagingScrollView;
// Set the content offset of the scrollview
CGRect bounds = pagingScrollView.bounds;
CGPoint contentOffset = CGPointMake(bounds.size.width * startingPage, 0.0f);
[pagingScrollView setContentOffset:contentOffset animated:NO];
// Step 2: prepare to tile content
recycledPages = [[NSMutableSet alloc] init];
visiblePages = [[NSMutableSet alloc] init];
[self tilePages];
}

Resources