UIPage Control custom style NatGeo - xcode

In my app I have UIView that flow through the use of a horizontal scrollView. To scroll the view I used the classimo method [self addChildViewController: [self.storyboard instantiateViewControllerWithIdentifier: # "name Storyboard ID"]];
Each UIView is followed through the use of UIPageControl classic, but I do not like it and so I wanted to create something like this (see photo)
as you can see from the images above application there is a menu with a triangle pointing down, Indicating the page, passing from one topic to another user through the horizontal swipe on the scrollView
In other words, instead of having the classic shot for the management of the pages, the National Geographic has used a triangle pointing down and the title of the page on which the user is ...
Could someone help me understand how can 'be created a similar PageControl?

There are a lot of approaches to implement this. Maybe the custom PageControl won't be the subclass of a UIPageControl.
For example, you can subclass a UIView, and put a UIScrollView in it. And then put a bunch of UIButtons in a row into the UIScrollView, each of them has a title that is your page's title. When you tap a button ( you can get this event by UIButton's -addTarget:action:forControlEvents:), you can scroll the tapped button to the right position, highlight it, and put a little triangle below it.
There are many possibilities. Say, you can replace the buttons with UILabel and add UITapGestureRecognizer to capture the users tap, or you can replace the UIScrollView with UITableView if you get a long list of pages(Of course that will introduce some complexity). You just need to pick your favorite and try it out.

Related

I need to customize tabBar

In my project I have two Views with TabBar and I would like to customize each one with different images.
Can anyone know how to do this?
If you are wishing to customize the tabs in your tab bar, that can done by creating a UITabBarItem using the init method below and assigning it to the tabBarItem property of each navigation controller that goes into your tab bar controller. This will display the given titles and images on each tab.
navigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"title"
image:[UIImage imageNamedB:#"tabImage.png"]
tag:0];
Osvaldo, If you want two different backgrounds for the two different view controllers of your tab bar project you have a couple of options. But I would do the following. Grab a UIView from the object library and place one in each vc so that it fills the whole view. Next you can place UIImageViews in the UIView you just placed. Four in the one vc and five in the other. Place them and size them to however you wish. You then need to import the pictures you want to place in them. Drag the image files into the left pane, the project outline. Make sure you copy to destination so they are a part of your project. Next in the vc's click on the UIImageView that you want the picture in. On the right pane under attributes there will be a drop down menu called image. Select the image you want and it will appear in the storyboard in the vc. Do this for all the UIImageViews that you have. When on storyboards, you can pop out the storyboard outline. Make sure the UIImageViews are within the UIView. Then select the UIView in the outline and go up to the editor menu, and select arrange, send to back. It may be grayed out if the UIView was the only thing you had on the vc in the beginning. So now, this UIView will act as a background, and you can customize them to look like anything you like. Hope this helps, let us know how it goes. If it works, please accept my answer, any other questions, just ask.

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..

detect scroll in horizontally uitableviewCell

I have UiTableView containing some data, and I want to scroll the UiTableViewCells horizontally to the left or right to show some UiButtons that act some action relatif to the content of the cell.
How Can I do this?
I'm thinking in creating custom cell, and putting a scrollView in it, May this did the trick?
There is a tutorial for this at http://idevrecipes.com/2011/04/14/how-does-the-twitter-iphone-app-implement-side-swiping-on-a-table/ with sample code. He is using a UISwipeGestureRecognizer to trigger an animation that pushes the cell off the screen.
You could use a swipe gesture recognizer attached to your cell.
You can add a UIScrollView to the contentView of a UITableViewCell. If you want to scroll the content using buttons, simply overlay the UIScrollView with buttons and make them call the various scrolling methods of UIScrollView.
Nested UIScrollView (UITableView inherits from UIScrollView) are quite clever about detecting touch conflicts and resolving the users intended gesture.
https://github.com/JonasGessner/JGScrollableTableViewCell might be what you're looking for. It implements this using a UIScrollView inside the cell (just like the iOS 7 mail app).
(Yes the answer is a bit late, but it's never too late! :P)

Table cell only is highlighted when you tap on the disclosure icon

I place a single table view cell on my view using interface builder and add an accessory type, a selection color and enable user interaction.
My problem is that the cell only is highlighted when the user taps on the arrow icon. But it also should be highlighted when the user taps on the text label inside it, he can tap anywhere on the cell.
How can I achieve this?
A UITableViewCell is really only meant to be used within the context of a UITableView (which knows how to handle and/or delegate the selection & highlighting of the cell).
Having a UITableViewCell outside of the context of a table is a somewhat unexpected user interface.
Couldn't you do what you want to do with a UIButton instead?
Or a UIView that has two UIButton subviews (or at least one UIButton subview to contain a widget graphic that looks like the disclosure accessory)? That way the things you want to get highlighted would definitely happen, as opposed to depending on a nonexistent [UITableView didSelectCellAtIndexPath:] method that doesn't exist in a view that isn't a UITableView delegate.

How to "stick" a UIScrollView subview to top/bottom when scrolling?

You see this in iPhone apps like Gilt. The user scrolls a view, and a subview apparently "sticks" to one edges as the rest of the scrollView slides underneath. That is, there is a text box (or whatever) in the scrollView, that as the scrollView hits the top of the view, then "sticks" there as the rest of the view continues to slide.
So, there are several issues. First, one can determine via "scrollViewDidScroll:" (during normal scrolling) when the view of interest is passing (or re-appearing). There is a fair amount of granularity here - the differences between delegate calls can be a hundred of points or more. That said, when you see the view approach the top of the scrollView, you turn on a second copy of the view statically displayed under the scrollView top. I have not coded this, but it seems like it will lack a real "stick" look - the view will first disappear then reappear.
Second, if one does a setContentOffset:animated, one does not get the delegate messages (Gilt does not do this). So, how do you get the callbacks in this case? Do you use KVO on "scroll.layer.presentationLayer.bounds" ?
Well, I found one way to do this. When the user scrolls by flicking and dragging, the UIScrollView gives its delegate a "scrollViewDidScroll:" message. You can look then to see if the scroller has moved the content to where you need to take some action.
When "sticking" the view, remove it from the scrollView, and then add it to the scrollView's superview (with an origin of 0,0). When unsticking, do the converse.
If you use the UIScrollView setContentOffset:animated:, it gets trickier. What I did was to subclass UIScrollView, use a flag to specify it was setContentOffset moving the offset, then start a fast running timer to monitor contentOffset.
I put the method that handles the math and sticking/unsticking the child view into this subclass. It looks pretty good.
Gilt uses a table view to accomplish this. Specifically, in the table view's delegate, these two methods:
– tableView:viewForHeaderInSection:
and – tableView:heightForHeaderInSection:

Resources