UIPageControl customization - ios

I'm trying to make something like UIPageViewController where I can swipe between different VC's. But instead of custom dot control I need to have custom buttons. So that either user can select different VC with button click or can swipe.
Right now I'm using UIScrollView to make this. I don't know how to proceed with buttons so I need help with that.
Is there any custom control that'll be useful for this?

You can do it in different ways. If you have three pages, you can create a UI with three buttons(or a tab bar) and in the action you can call:
[self.pageViewController setViewControllers:#[[self viewControllerAtIndex:YourPageIndex]
direction:UIPageViewControllerNavigationDirectionReverse
animated:YES
completion:nil];
UIPageViewControllerNavigationDirectionReverse or UIPageViewControllerNavigationDirectionForward can be used as required.
This is how we do it.
Or you can use any custom libraries:
Carbon kit is a working library. Here you can find many of them.
OR TRY THIS( a simpler example on carbon kit )

Related

What is the most standard approach to creating a separate menu which can be displayed over a single view controller

Apologize in advance as I'm still new to Xcode.
I have a 2D game build entirely in one viewController. I would like to add both a start menu and in game menu to the game. I assume the best way to do this is through another instance of a viewController? Any advice or suggestions would be very helpful.
First place a UIView on your Xib or UIStoryboard.
Put 2 buttons on it and make their connections and outlets.
The view you want to open is view_Menu.( let us consider)
Now for managing view you need to do this:
view_Menu.frame = CGRectMake(xAxis, yAxis, self.view.frame.size.width, 150);
[self.view addSubView: view_Menu];
In xAxis and yAxis you can put your values.
Now when you click any button inside the menu view you can simply call this method:
[view_Menu RemoveFromSuperview];
So it will help to provide you that you want. A bit of things that you can put a background image or make some custom animations for better look.

Set layers programmatically

so I have an application with several images, buttons, etc.. Now, I would like to control programmatically which object is in the foreground and which is further in the back. I know that in the storyboard this is possible, but since I declare a button in the AppDelegate (I don't have in the storyboard) I can't use this function.
Now, is there a way to do this?
You have to use the property .zPosition to accomplish that.
Look at the "Managing View Hierachy" section on UIView to accomplish this.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/doc/uid/TP40006816-CH3-SW46
You can bring views to the front or send them to the back or adjust their index among others.
- (void)bringSubviewToFront:(UIView *)view

Implementing a "context menu" with a grid of buttons

I'm wondering whether there's a better way of implementing a "context menu" in my app. This is a screenshot of how it currently looks like and as you can see, almost the entire screen is already filled up with entries:
This is actually a UIAlertView with multiple "other" buttons.
I wondered if it's possible to create sort of a grid layout within the alert view and add three buttons per row which show icons only, instead of labels (in order to save some space). I'd like to make it similar to this (photoshopped) layout:
I read that it's possible to create a popup with custom stuff in it by using a UIView but perhaps you guys know an easier trick of accomplishing the same thing with an UIAlertView.
Is this even possible with an alert view?
it's impossible to create an UIAlertView like this.. Create a new UIView and add it to your viewController with [self.view addSubview:..]
You should use UIActionSheet instead of UIAlertView in this case. Or you can use modalViewController something like this: http://timneill.net/2010/09/modal-view-controller-example-part-1/

Swipe between different screens (views) using storyboards

In my project, I'm using the storyboard with 2 tabs. What I want to create is in the first tab, when you swipe left, another layout with text will show and when you swipe left again, another layout shows with other information (so lets say I want 10 different layout templates but I need to be able to change the text from the layout templates.
So this is my storyboard:
And in the "First View" I need to be able to swipe left and show a layout with text, swipe left again and show (for example) the same layout with another text, swipe left again show another layout with text and so on. So in total there are 10 layout templates where I need to be able to change the text in code.
So basically what I'm aiming for is the same as the start window on the iPhone/iPad where you can swipe between the screens where the app icons are on. How can I accomplish this with the same animation?
What you are looking for is called UIPageControl. The class reference can be found here and a really good tutorial can be found here.
If you want a more fancy UIPageControl with more customizable options I suggest you try out any of these. (The SMPageControl is one of my own personal favorites)
EDIT due to comments:
Here is a link to the project from the tutorial above.
In CustomPagerViewController he calls
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:#"View1"]];
which gives the equivalent result as
UIViewController *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"View1"];
[self addChildViewController:aViewController];
Now, if you want to add several ViewControllers you could do a loop as follows
for(int i = 0; i<yourNumberOfViewControllers; i++) {
YourViewControllerClass *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"YourIdentifier"];
[aViewController setSomeProperty:someValue];
[self addChildViewController:aViewController];
}
Hope it helps!

Draggable ViewController like the iPhone facebook app

I'm wondering how to go about implementing a draggable viewcontroller such as that in the Facebook app where the user can drag from the far left of the screen to the right and the viewcontroller will follow, revealing another view underneath. I'm not looking to rip off this design, I just find it to be a very interesting way to display extra information and I'd like to learn more about draggable interfaces.
Now I'm somewhat familiar with UIPanGestureRecognizers but I imagine this is far more complex?
Where would I start?
I've used this with pretty good luck:
ECSlidingViewController
I did my research on all the options at the time (like a month ago) and this is most like facebooks because you can drag anywhere on the screen to move it. Also this supports both orientations
You can find solution here: How to move an UIViewController?
In that example you can drag viewControllers by swiping navigationBar
In that example FronViewController viewDidLoad method contains code:
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:#selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
and ZUUIRevealController contains method to handle recognizer:
- (void)revealGesture:(UIPanGestureRecognizer *)recognizer

Resources