Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. - (id)init
  2. {
  3. self = [super init];
  4. if (self) {
  5. self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 390, 320, 390)];
  6. self.view.backgroundColor = [UIColor clearColor];
  7. closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 370, 320, 20)];
  8. helpButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 160, 40)];
  9. aboutButton = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 160, 40)];
  10. scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, helpButton.frame.size.height, 320, (390 - helpButton.frame.size.height - closeButton.frame.size.height))];
  11. [self loadView];
  12. }
  13. return self;
  14. }
  15.  
  16. - (void)dealloc
  17. {
  18. NSLog(@"bYE bUE");
  19. [helpButton release];
  20. [aboutButton release];
  21. [closeButton release];
  22. [scrollView release];
  23. [super dealloc];
  24. }
  25.  
  26. #pragma mark - View lifecycle
  27.  
  28.  
  29. -(void)switchViews:(UIButton *)sender {
  30. if ([sender.currentTitle isEqualToString:@"Ayuda"]){
  31. UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
  32. [helpview setBackgroundColor:[UIColor redColor]];
  33. scrollView.contentSize = CGSizeMake(320, 1000);
  34. [scrollView insertSubview:helpview atIndex:1];
  35. [helpview release];
  36. } else if ([sender.currentTitle isEqualToString:@"Sobre"]) {
  37. UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
  38. [helpview setBackgroundColor:[UIColor blueColor]];
  39. scrollView.contentSize = CGSizeMake(320, 1000);
  40. [scrollView insertSubview:helpview atIndex:1];
  41. [helpview release];
  42. }
  43. [scrollView exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
  44. scrollView.contentOffset = CGPointMake(0, 0);
  45. [[scrollView.subviews objectAtIndex:1] removeFromSuperview];
  46. }
  47. - (void)loadView
  48. {
  49. //Lets set the Buttons;
  50. [helpButton setTitle:@"Ayuda" forState:UIControlStateNormal];
  51. helpButton.backgroundColor = [UIColor whiteColor];
  52. [helpButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  53. [helpButton setTitle:@"Ayuda" forState:UIControlStateSelected];
  54. [helpButton addTarget:self action:@selector(switchViews:) forControlEvents:UIControlEventTouchUpInside];
  55.  
  56. [aboutButton setTitle:@"Sobre" forState:UIControlStateNormal];
  57. aboutButton.backgroundColor = [UIColor whiteColor];
  58. [aboutButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  59. [aboutButton addTarget:self action:@selector(switchViews:) forControlEvents:UIControlEventTouchUpInside];
  60.  
  61. [closeButton setTitle:@"Cerrar" forState:UIControlStateNormal];
  62. closeButton.backgroundColor = [UIColor whiteColor];
  63. [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  64. [closeButton addTarget:nil action:@selector(closeHelp) forControlEvents:UIControlEventTouchUpInside];
  65.  
  66. UIView *helpview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
  67. [helpview setBackgroundColor:[UIColor redColor]];
  68. scrollView.contentSize = CGSizeMake(320, 1000);
  69. [scrollView insertSubview:helpview atIndex:0];
  70. [helpview release];
  71.  
  72.  
  73. //Add buttons to view
  74. [self.view addSubview:helpButton];
  75. [self.view addSubview:aboutButton];
  76. [self.view addSubview:closeButton];
  77. [self.view addSubview:scrollView];
  78.  
  79. }
Add Comment
Please, Sign In to add comment