stefanlage / slpagingview Goto Github PK
View Code? Open in Web Editor NEWNavigation bar system allowing to do a Tinder like or Twitter like
License: MIT License
Navigation bar system allowing to do a Tinder like or Twitter like
License: MIT License
I tried:
SLPagingViewController(navBarItems: items, controllers: controllers, showPageControl: false)
but only the navigation header shows up.
Hi! @StefanLage
Thank you very much for your open source libraries.
The NavigationBar icon main color how i can change it?
Jack
Hello, I got some displaying issue in the navigation bar please check the image 'I want my nav bar looks like twitter'
Also My CollectionView was resizing when rotating but after adding SLPagingView it doesn't resize any more I tried to add this code to didLoadView method in SLpagingView but haven't helpd :
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
I'm using storyboard as in tinder example (and I'haven't added any code) I just subclassed from SLPagingView and I add the costum Segue that's all
When I present the paging view with my three view controllers, they are all deallocated. Is there a reason they are not kept around?
How can I set this to show my view controllers instead of showing the UIColors
I was thinking that I would be able to do it in the views NSArray
NSArray *titles = @[[[UIImageView alloc] initWithImage:img1], [[UIImageView alloc] initWithImage:img2], [[UIImageView alloc] initWithImage:img3]];
NSArray *views = @[[self viewWithBackground:orange], [self viewWithBackground:[UIColor yellowColor]], [self viewWithBackground:gray]];
SLPagingViewController *pageViewController = [[SLPagingViewController alloc] initWithNavBarItems:titles
navBarBackground:[UIColor whiteColor]
views:views
showPageControl:NO];
I'm coding on swift and using your storyboard to create an example but when present a modal view and dismiss it, the layout of view controllers is broken.
Please help me solve this problem.
Thank you
Is there a way to add a button to the nav bar that responds to a selector as opposed to being another view than you can swipe to? And it will only appear on the farthest right view in the SLPagingView?
This possibly could be my install of cocoa pods is messed up but it is unlikely. I am unable to install this via cocoa pods from github or just by refrencing
pod 'SLPagingView'
i have also tried referencing the github repository
pod 'SLPagingView', :git => 'https://github.com/StefanLage/SLPagingView.git'
I have spend quite awhile trying to rule out my cocoa pods install but i have successfully installed other pods.
Any help would be appreciated. Thanks for this awesome control!
I've been having an issue using the standard PickerView (spinning wheel) not only inside one of the view controllers under the purview of SLPagingViewController, but also inside of modal popups that seems shouldn't be affected by it. Basically, the spinning-wheel wobbles in every possible direction, doesn't rotate properly at all, with tapping (not swiping/spinning) being the only way to select a value.
Below are the screenshots of how it looks when you try to spin it. To experience, simply add the most basic PickerView implementation to the TinderStoryboard example (code below).
Any thoughts on how to fix this would be helpful since I'm yet to find a solution/cause.
CODE:
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *logo = [UIImage imageNamed:@"profile"];
logo = [logo imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_titleView = [[UIImageView alloc] initWithImage:logo];
self.navigationItem.titleView = self.titleView;
// Do any additional setup after loading the view, typically from a nib.
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
_pickerData = @[@"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 5", @"Item 6"];
}
NSArray *_pickerData;
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (int)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return _pickerData.count;
}
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return _pickerData[row];
}
I have an iOS app where ViewController is the default view controller. The implementation of ViewController looks like this
#import "ViewController.h"
#import "SLPagingViewController.h"
#import "UIColor+SLAddition.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated {
UIColor *orange = [UIColor colorWithRed:255/255
green:69.0/255
blue:0.0/255
alpha:1.0];
UIColor *gray = [UIColor colorWithRed:.84
green:.84
blue:.84
alpha:1.0];
UIImage *img1 = [UIImage imageNamed:@"gear"];
img1 = [img1 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImage *img2 = [UIImage imageNamed:@"profile"];
img2 = [img2 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImage *img3 = [UIImage imageNamed:@"chat"];
img3 = [img3 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
NSArray *titles = @[[[UIImageView alloc] initWithImage:img1], [[UIImageView alloc] initWithImage:img2], [[UIImageView alloc] initWithImage:img3]];
UIView *orangeView = [self viewWithBackground:[UIColor orangeColor]];
UIView *yellowView = [self viewWithBackground:[UIColor yellowColor]];
UIView *blueView = [self viewWithBackground:[UIColor blueColor]];
NSArray *views = @[orangeView, yellowView, blueView];
SLPagingViewController *pageViewController = [[SLPagingViewController alloc] initWithNavBarItems:titles
navBarBackground:[UIColor whiteColor]
views:views
showPageControl:NO];
pageViewController.navigationSideItemsStyle = SLNavigationSideItemsStyleOnBounds;
float minX = 45.0;
// Tinder Like
pageViewController.pagingViewMoving = ^(NSArray *subviews){
float mid = [UIScreen mainScreen].bounds.size.width/2 - minX;
float midM = [UIScreen mainScreen].bounds.size.width - minX;
for(UIImageView *v in subviews){
UIColor *c = gray;
if(v.frame.origin.x > minX
&& v.frame.origin.x < mid)
// Left part
c = [UIColor gradient:v.frame.origin.x
top:minX+1
bottom:mid-1
init:orange
goal:gray];
else if(v.frame.origin.x > mid
&& v.frame.origin.x < midM)
// Right part
c = [UIColor gradient:v.frame.origin.x
top:mid+1
bottom:midM-1
init:gray
goal:orange];
else if(v.frame.origin.x == mid)
c = orange;
v.tintColor= c;
}
};
[pageViewController setNavigationBarColor:[UIColor greenColor]];
[self presentViewController:pageViewController animated:YES completion:nil];
}
-(UIView*)viewWithBackground:(UIColor *)color{
UIView *v = [UIView new];
v.backgroundColor = color;
return v;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
However, with the above code, the orange, yellow and blue views fill the whole screen and the tabs are not visible. How do I make the tabs visible?
I'm trying to have a twitter style headers (titles replacing one another).
I'm using storyboard controllers.
When the view loads I get this image:
When I just touch the swipe, I get what I expected to see - the "Feedme" title disappears (appears nicely when actually swiping to the second controller) - like so:
How can I make it appear correctly on initial load.
The code:
MainTabBarViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
c.selectedIndex = 1; //feed
UINavigationController *nav = (UINavigationController *)[c.childViewControllers objectAtIndex:1];
SLPagingViewController *pageViewController = (SLPagingViewController *)[nav.viewControllers objectAtIndex:0];
pageViewController.navigationSideItemsStyle = SLNavigationSideItemsStyleDefault;
pageViewController.pagingViewMovingRedefine = ^(UIScrollView *scrollView, NSArray *subviews){
float mid = [UIScreen mainScreen].bounds.size.width/2 - 45.0;
float width = [UIScreen mainScreen].bounds.size.width;
CGFloat xOffset = scrollView.contentOffset.x;
int i = 0;
for(UILabel *v in subviews){
CGFloat alpha = 0.0;
if(v.frame.origin.x < mid)
alpha = 1 - (xOffset - i*width) / width;
else if(v.frame.origin.x >mid)
alpha=(xOffset - i*width) / width + 1;
else if(v.frame.origin.x == mid-5)
alpha = 1.0;
i++;
v.alpha = alpha;
}
};
[pageViewController setCurrentIndex:0 animated:NO];
pageViewController.needToShowPageControl = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:c animated:YES completion:nil];
});
@StefanLage
Hi!
If content page very more, 20 or 30 page.
support reuse content page like UITableView DataSource or UICollectionView DataSource is very cool thing.:+1:
Jack
(label it a question)
I have 2 ViewControllers to use.
Basically they contain only a UITableView
- like the twitter example - but the thing is that they are completely different (which is not a problem, the delegates can handle it with conditions)
But has a lot of extra functionality (catch click on the UITabBar
to refresh and scroll up, swipe up to refresh etc.)
I'm having trouble understanding what should I implement - can I have my UIViewController
subclass SLPagingViewController
?
(I can't just add tableview views like the example - it's not enough)
Or should I have 2 UIViewControllers
(like the tinder example) and make them share relevant code outside the logic of SLPagingViewController
?
viewWillDisappear is not being called when page changes.
Integrating UITableviewController Not Updating Tableview Datasource.
Is there any way for refreshing particular tableview controller datasource and ui.
I'got project that's look like this :
So the problem if I try to push view from one of the pager View (the red or yellow one ...) it won't work because self.navigationController is null, how to fix it ? {code Example to push view from the yellow screen}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"bundle:nil];
PostReaderViewController *postReaderView =
(PostReaderViewController *)
[storyboard instantiateViewControllerWithIdentifier:@"postReaderView"];
NSLog(@"%@", self.navigationController);
[self.navigationController pushViewController:postReaderView animated:YES];
Hi,
I was wondering if there is a way to change the navigation bar's background color using Storyboard. I saw that you manage it in navigationBarView
but it's a private property, I can't change.
Thanks for the great work!
Im trying to use this in a navigation controller. I present a login page and after the user logs in I present my SLPagingView, but when it gets presented self.navigationController is null so I cant push anything else.
I've looked at #19, but thats still not working for me.
I've tried everything, please help!
I'm new in iOS development. I see this in .h
/*
Please can You explain me how I can notice me about changing the viewController using this blocks?
I've implement this in my appDelegate:
pageViewController.didChangedPage = ^(NSInteger interr) {
NSLog(@"SOMETHING");
[[NSNotificationCenter defaultCenter] postNotificationName:@"Sergey" object:nil userInfo:nil];
NSLog(@"%i", interr);
};
(use this in demo app in appDelegate).
I've implement notification and addObserver in another controller but nothing happen. And all three controllers dealloc.
And how can I call viewDidAppear from my controller.
And also I notice that this block return me number 1 and 2. And did't return the number of my first controller. Is it the bug?
How can I say my controller that it is now display on the screen and it should be update?
Hi. I had to remove SLPagingView from my project because of this behaviour. It's hard to explain but, basically, when loading a html with a combo box (select element) within it, you can't select any option because every time you scroll the Picker View that appears at the bottom and lift your finger, the default option is selected; though if you tap an directly to an option it works but it is not the intended behaviour of a Picker View. Also the Picker View can be scrolled to the left and to the right and then it returns to the correct position but with the same bad behaviour.
To replicate this, just create a brand new project, pod install SLPagingView and use this code in the ViewController.m:
#import <WebKit/WebKit.h>
.
.
.
@interface ViewController ()
@property (strong, nonatomic) WKWebView *theWebView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_theWebView = [[WKWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:_theWebView];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com/some_html_with_select_element.html"]];
[_theWebView loadRequest:request];
}
Fortunately, the project I'm working on wasn't making use of SLPagingView so I could removed it.
Is it possible to place pagingbar/tabbar on bottom?
Very nice project I was looking for but,
How to use this with ViewControllers instead of Views ?
Hello, I'm trying to use this library in storybord so I've designed my different views in storyBorad then I added this code in app delegate :
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SubBaseCollection2 *view1 = (SubBaseCollection2 *)[storyboard instantiateViewControllerWithIdentifier:@"subView2"];
SubBaseCollection *view2 = (SubBaseCollection *)[storyboard instantiateViewControllerWithIdentifier:@"subView1"];
UIViewController *view3 = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"subView3"];
SLPagingViewController *pageViewController = [[SLPagingViewController alloc] initWithNavBarControllers:@[view3, view1, view2]];
UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:pageViewController];
self.window.rootViewController = navC;
This work when I navigate to right but If I go back my app crash.
check My sample code over here : https://drive.google.com/file/d/0Bx1q874uh9xwZVJNdlZRejRQM00/view?usp=sharing
I'm using KNSemiModalViewController and SLPagingView together, but SLPagingView.scrollview frame is fixed, so subview's contentSize and frame is wrong.
Wondering if we can use this without auto constraints? I'm going to be targeting only the iPhone 5 screen so using autoresizing masks (springs/struts) is much faster than setting up constraints.
I tried using it without auto constraints, but I'm getting this error:
The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7d166fe0 H:[UIView:0x7d160ef0]-(0)-[UIView:0x7d161970]>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
Assertion failure in -[UIScrollView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/NSLayoutConstraint_UIKitAdditions.m:560
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
I add the SLPagingViewController in a tabbar, the library doesn't change of view, and If I touch or swipe, both doesn't respond.
This only happens with iOS 7. iOS 8 works.
There is a minor bug when from the child views (or viewcontroller views) some use Autolayout and some don't.
I will create a pull request.
I'm not sure if this was a typo or what, but you've set up these two pointers like so
typedef void(^SLPagingViewMoving)(NSArray *subviews);
typedef void(^SLPagingViewMovingRedefine)(UIScrollView *scrollView, NSArray *subviews);
But your referencing one like this
pageViewController.pagingViewMoving = ^(UIScrollView _scrollView, NSArray *subviews){
CGFloat xOffset = scrollView.contentOffset.x;
int i = 0;
for(UILabel v in subviews){
CGFloat alpha = 0.0;
if(v.frame.origin.x < 145)
alpha = 1 - (xOffset - i_320) / 320;
else if(v.frame.origin.x >145)
alpha=(xOffset - i320) / 320 + 1;
else if(v.frame.origin.x == 140)
alpha = 1.0;
i++;
v.alpha = alpha;
}
};
which throws a Fatal Error in Xcode 6 because the block your referencing doesn't contain "scrollView"
UIViewController lifecycle events (view[Will | Did][Load | Appear | Disappear]) should not be sent manually but handled with the View Controller Containment API (willMoveToParentViewController, addChildViewController, didMoveToParentViewController)
This was working fine until I tried it on an iOS 9 device. The pageControl also is not updating where it was working fine before I tried iOS 9. Any thoughts?
__weak typeof(self)weakSelf = self;
self.didChangedPage = ^(NSInteger currentPageIndex) {
// do something
NSLog(@"page index: %i | scrollView: %@", (int)currentPageIndex, NSStringFromCGRect(weakSelf.scrollView.frame));
};
Hello, I am new to iOS development and honestly not sure where to start with what I'm attempting to build or how to phrase my question. I have a login page and once a user logs in I'd like to call for this type of paging. How would I go about doing so, making SLPagingView once a user logs in instead of in the app delegate file
Hello,
Like tinder, when user is on a page, I'd like to change the bar item to a UILabel (previously is a UIImage).
2.Where should i change the bar item, didChangePage block or pagingViewMovingRedefine block?
Thanks in advance.
I have integrated SLPagingView in one of my viewcontroller by inheriting from SLPagingViewController.
Now I tried to push another ViewController from this one and the pushed one had wrong contentsize - (1135, 504) and it can be moved horizontally when dragging.
Very weird.
Please can You explain me what I do wrong?
In my appDelegate
@interface AppDelegate ()
@implementation AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ChatViewController *chat = (ChatViewController *)[storyboard instantiateViewControllerWithIdentifier:@"Chat"];
ProfileViewController *profile = (ProfileViewController *)[storyboard instantiateViewControllerWithIdentifier:@"Profile"];
SettingsViewController *settings = (SettingsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"Settings"];
SLPagingViewController *pageViewController = [[SLPagingViewController alloc] initWithNavBarControllers:@[settings, chat, profile]];
UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:pageViewController];
//UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:pageViewController];
//self.window.rootViewController = pageViewController;
self.window.rootViewController = navC;
return YES;
}
Then in my ChatController:
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"APPEAR");
}
-(void)dealloc{
NSLog(@"DEALLOC");
}
and in my console I see only DEALLOC. And APPEAR I didn't see.
Please explain what I am doing wrong?
I'm looking to use SLPagingView on the top level of a UINavigationController stack, but hide it on all others. I've been playing with the implementation and I've found that by exposing the navigationBarView, I can hide this when necessary. I can create a pull request with the fix, but I wanted to get your thoughts on exposing this otherwise private attribute.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.