Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.84 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I put this UILabel code outside of my AppDelegate?
  2. CGRect frame = CGRectMake(10, 10, 300, 25);
  3.  UILabel *helloLabel = [UILabel new];
  4.  [helloLabel setFrame:frame];
  5.  helloLabel.text = @"Hello iPhone!";  
  6.  [self.window addSubview:helloLabel];
  7.        
  8. [MyOtherClass addHello];
  9.        
  10. + (void) addHello {
  11.  
  12. CGRect frame = CGRectMake(10, 10, 300, 25);
  13. UILabel *helloLabel = [UILabel new];
  14. [helloLabel setFrame:frame];
  15. helloLabel.text = @"Hello iPhone!";
  16.  
  17. UIWindow *window = [[UIApplication sharedApplication] keyWindow];
  18. [window addSubview:helloLabel];
  19.  
  20. }
  21.        
  22. [MyOtherClass addHelloWithWindow:self.window];
  23.        
  24. + (void) addHelloWithWindow:(UIWindow *)window
  25. {
  26.     CGRect frame = CGRectMake(10, 10, 300, 25);
  27.     UILabel *helloLabel = [UILabel new];
  28.     [helloLabel setFrame:frame];
  29.     helloLabel.text = @"Hello iPhone!";
  30.     [window addSubview:helloLabel];
  31. }