ealeksandrov / EAIntroView

Highly customizable drop-in solution for introduction views.
MIT License
3.76k stars 501 forks source link

Add buttons in all pages #4

Closed tunidev closed 10 years ago

tunidev commented 10 years ago

Hello,

1/ I want to add buttons in all pages, the same buttons just like Wunderlist app you can see it in action in this screen shot

1

after adding them how can I handle their actions, in other word, if the user is viewing for example the second page and then he clicked on the "sign up" button how to handle that

2/ I want to avoid the "Intro callback", I just want to implement for example 4 pages, when the user reach the last page he is stack there he only can back to previous views or click the buttons implemented in "1/"

ealeksandrov commented 10 years ago
  1. You can create UIView with your own buttons, attached to actions, and pass it to titleView property of EAIntroView. This way your custom view will float above all scrollable content. If you want separate buttons on each page - pass them inside custom views in pageWithCustomView:.
  2. Switch swipeToExit property to NO. And if you are adding all buttons in your custom view - pass nil to skipButton.
tunidev commented 10 years ago

Hello,

Thank you for your fast replay, I tried your solution and it solves the second problem, but in the first one the buttons are added in the top of the page, and from the user experience perspective, it's more intuitive to have the buttons in the bottom of the page, just like the screen shot that I have attached in my first post here is the code that I have tried with the screenshot of the result :

EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.view.bounds andPages:@[page1,page2]];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Sign up" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
button.backgroundColor = [UIColor blackColor];

intro.swipeToExit = NO ;
intro.skipButton = nil ;
intro.titleView = button;

ios simulator screen shot oct 10 2013 10 37 35 pm

 EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.view.bounds andPages:@[page1,page2]];

UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 300, 40.0)];
myView.userInteractionEnabled = YES ;

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Sign up" forState:UIControlStateNormal];
button.frame = CGRectMake(20.0, 440.0, 100.0, 40.0);
button.backgroundColor = [UIColor whiteColor];

UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 addTarget:self
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
[button2 setTitle:@"Login" forState:UIControlStateNormal];
button2.frame = CGRectMake(160, 440.0, 100.0, 40.0);
button2.backgroundColor = [UIColor lightGrayColor];

[myView addSubview:button];
[myView addSubview:button2];

intro.swipeToExit = NO ;
intro.skipButton = nil ;
intro.titleView = myView;

ios simulator screen shot oct 10 2013 10 33 53 pm

tunidev commented 10 years ago

Hello,

I ended up with playing with "intro.titleViewY" and "pageControlY" to reach this result

ios simulator screen shot oct 11 2013 12 34 22 am

here is the code

 EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.view.bounds andPages:@[page1,page2]];

 UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 300, 40.0)];
 myView.userInteractionEnabled = YES ;

 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 [button addTarget:self
 action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
 [button setTitle:@"Sign up" forState:UIControlStateNormal];
 button.frame = CGRectMake(20.0, 0, 100.0, 40.0);
 button.backgroundColor = [UIColor whiteColor];

 UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 [button2 addTarget:self
 action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
 [button2 setTitle:@"Login" forState:UIControlStateNormal];
 button2.frame = CGRectMake(180, 0, 100.0, 40.0);
 button2.backgroundColor = [UIColor lightGrayColor];

 [myView addSubview:button];
 [myView addSubview:button2];

 intro.swipeToExit = NO ;
 intro.skipButton = nil ;
 intro.titleView = myView;

intro.titleViewY = 480. ;
intro.pageControlY = 200. ;

But now I figure out that the buttons are not visible in the 3.5" screen size, any solution ?

EDIT : I solved that by changing the line

intro.titleViewY = 480. ;

to

intro.titleViewY = [UIScreen mainScreen].bounds.size.height - 60;

ealeksandrov commented 10 years ago

Yes, UIView as a container for your custom buttons is the solution. Hope you have reached the desired layout.