Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (id)init
- {
- self = [super init];
- if (self) {
- self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 390, 320, 390)];
- self.view.backgroundColor = [UIColor clearColor];
- closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 370, 320, 20)];
- helpButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 160, 40)];
- aboutButton = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 160, 40)];
- scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, helpButton.frame.size.height, 320, (390 - helpButton.frame.size.height - closeButton.frame.size.height))];
- [self loadView];
- }
- return self;
- }
- - (void)dealloc
- {
- NSLog(@"bYE bUE");
- [helpButton release];
- [aboutButton release];
- [closeButton release];
- [scrollView release];
- [super dealloc];
- }
- #pragma mark - View lifecycle
- -(void)switchViews:(UIButton *)sender {
- if ([sender.currentTitle isEqualToString:@"Ayuda"]){
- UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
- [helpview setBackgroundColor:[UIColor redColor]];
- scrollView.contentSize = CGSizeMake(320, 1000);
- [scrollView insertSubview:helpview atIndex:1];
- [helpview release];
- } else if ([sender.currentTitle isEqualToString:@"Sobre"]) {
- UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
- [helpview setBackgroundColor:[UIColor blueColor]];
- scrollView.contentSize = CGSizeMake(320, 1000);
- [scrollView insertSubview:helpview atIndex:1];
- [helpview release];
- }
- [scrollView exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
- scrollView.contentOffset = CGPointMake(0, 0);
- [[scrollView.subviews objectAtIndex:1] removeFromSuperview];
- }
- - (void)loadView
- {
- //Lets set the Buttons;
- [helpButton setTitle:@"Ayuda" forState:UIControlStateNormal];
- helpButton.backgroundColor = [UIColor whiteColor];
- [helpButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [helpButton setTitle:@"Ayuda" forState:UIControlStateSelected];
- [helpButton addTarget:self action:@selector(switchViews:) forControlEvents:UIControlEventTouchUpInside];
- [aboutButton setTitle:@"Sobre" forState:UIControlStateNormal];
- aboutButton.backgroundColor = [UIColor whiteColor];
- [aboutButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [aboutButton addTarget:self action:@selector(switchViews:) forControlEvents:UIControlEventTouchUpInside];
- [closeButton setTitle:@"Cerrar" forState:UIControlStateNormal];
- closeButton.backgroundColor = [UIColor whiteColor];
- [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [closeButton addTarget:nil action:@selector(closeHelp) forControlEvents:UIControlEventTouchUpInside];
- UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
- [helpview setBackgroundColor:[UIColor redColor]];
- scrollView.contentSize = CGSizeMake(320, 1000);
- [scrollView insertSubview:helpview atIndex:0];
- [helpview release];
- //Add buttons to view
- [self.view addSubview:helpButton];
- [self.view addSubview:aboutButton];
- [self.view addSubview:closeButton];
- [self.view addSubview:scrollView];
- }
Add Comment
Please, Sign In to add comment