Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Examples of usage

PaulTaykalo edited this page Nov 13, 2012 · 4 revisions

Examples of usage

UIView re-layouting

- (void)updateOnClassInjection {    
   [self setNeedsLayout];  
   [self setNeedsDisplay];
}

UIViewControllers view re-creation

- (void)updateOnClassInjection {    
   if ([self isViewLoaded]) {
      UIView * viewSuperView = view.superview;
      [self.view removeFromSuperview];
      self.view = [self recreateView]; // <-- Custom metod of view recreation
      [viewSuperView addSubview:[self view]];
   }
}

UIViewControllers locations (Debugging purposes)

// Helpful, when you are new to the project and 
// have lost in big about of view controllers
// And you don't know which controller are you currently see
// This method was found in base (__PROJECTPREFIX__)ViewController
- (void)updateOnClassInjection {
   if ([self isViewLoaded]) {

      // Adding to each view controller view
      // Label with it's class name
      [[[self view] viewWithTag:1000] removeFromSuperview];

      UILabel * label = [[UILabel alloc] init];
      label.text = NSStringFromClass([self class]);
      [label sizeToFit];
      label.center = CGPointMake(self.view.width / 2, 0);
      label.top = 20;
      label.tag = 1000;
      [[self view] addSubview:label];

      [label setBackgroundColor:[UIColor greenColor]];
      
   }
}

Clone this wiki locally