Guest User

Untitled

a guest
Jul 17th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. //
  2. // JokeView.m
  3. // Blonde Jokes
  4. //
  5. // Created by Samuel Gleitman on 11/8/09.
  6. // Copyright 2009 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "JokeView.h"
  10.  
  11.  
  12. @implementation JokeView
  13.  
  14. - (id)initWithJokeNumber:(int)number {
  15. self.frame=CGRectMake(0, 0, 320, 373);
  16. self.backgroundColor = [UIColor yellowColor];
  17. if (self = [super init]) {
  18. jokeNumber = number;
  19. }
  20. return self;
  21. }
  22.  
  23. /*
  24. // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  25. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  26. if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  27. // Custom initialization
  28. }
  29. return self;
  30. }
  31. */
  32.  
  33.  
  34. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  35. - (void)loadView {
  36.  
  37. if(!jokeNumber)
  38. jokeNumber = 1;
  39.  
  40.  
  41. NSArray *jokesArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BlondeJoke" ofType:@"plist"]];
  42. NSString *jokeString = [jokesArray objectAtIndex:(jokeNumber - 1)];
  43.  
  44. UITextView *jokeText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 372)];
  45. [jokeText setFont:[UIFont boldSystemFontOfSize:18]];
  46. [jokeText setBackgroundColor:[UIColor yellowColor]];
  47. [jokeText setTextColor: [UIColor blackColor]];
  48. [jokeText setText:jokeString];
  49. [self addSubview:jokeText];
  50. [jokeText setEditable:NO];
  51.  
  52.  
  53. }
  54.  
  55.  
  56. /*
  57. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  58. - (void)viewDidLoad {
  59. [super viewDidLoad];
  60. }
  61. */
  62.  
  63. /*
  64. // Override to allow orientations other than the default portrait orientation.
  65. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  66. // Return YES for supported orientations
  67. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  68. }
  69. */
  70.  
  71. /*
  72. - (void)didReceiveMemoryWarning {
  73. // Releases the view if it doesn't have a superview.
  74. [super didReceiveMemoryWarning];
  75.  
  76. // Release any cached data, images, etc that aren't in use.
  77. }
  78.  
  79. */
  80. - (void)viewDidUnload {
  81. // Release any retained subviews of the main view.
  82. // e.g. self.myOutlet = nil;
  83. }
  84.  
  85.  
  86. - (void)dealloc {
  87. [super dealloc];
  88. }
  89.  
  90.  
  91. @end
Add Comment
Please, Sign In to add comment