title: Calling custom designed UIAlertView inside custom designed UIAlertView
body: <p>I'm struggling against this problem for days. </p>
  
  <p>I have a custom designed UIAlertView (A new UIAlertView inherited class whose name is ProductAlertView) and I want to open a new custom designed UIAlertView (that is also a UIAlertView inherited class). When I create this new custom designed UIAlertView inside the custom designed alertview,  new designed alertview isn't seen well (some images lost...) 
  Also, I tried to implement a singleton class which closes the first alertview then opens the second alertview; however, it didn't change that the view isn't seen fully and well again.</p>
  
  <p>Does anyone have solution for that?</p>
  
  <p>Some code:</p>
  
  <p>First AlertView</p>
  
  <pre><code>#import "ProductAlertView.h"
  #import &lt;QuartzCore/QuartzCore.h&gt;
  #import "cocos2d.h"
  #import "MessageAlertView.h"
  #import "Communicator.h"
  #import "MainGameScene.h"
  #import "UpdateMe.h"
  
  @implementation ProductAlertView
  @synthesize image;
  @synthesize unitId;
  @synthesize player_id;
  @synthesize location_id;
  @synthesize unitName;
  @synthesize currentLevel;
  @synthesize tab1Name;
  @synthesize alertName;
  @synthesize imageTab1;
  @synthesize buttonTab1;
  @synthesize scrollView;
  @synthesize productArray;
  @synthesize seller_id;
  
  //int MAXLEVEL = 5;
  
  
  -(void) drawRect:(CGRect)rect{
      CGSize size = self.image.size;
      [self.image drawInRect:CGRectMake(0, 0, size.width, size.height)];
  }
  
  
  
  - (void) show {
      // Test the labels
  
  
      // call the super show method to initiate the animation
      [super show];
  
      // resize the alert view to fit the image
      CGSize imageSize = self.image.size;
      self.bounds = CGRectMake(0, 0, imageSize.width, imageSize.height);
  
  
  
      scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(6, 40, 440, 180)];
      [scrollView setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.20]];
      scrollView.layer.cornerRadius = 10;
      //scrollView.alpha = 1.0;
      int i;
      int j = 2;
      for (i = 0; i &lt; [productArray count]; i++) {
          NSDictionary *unitDict = [productArray objectAtIndex:i];
          UIImage *image2 = [UIImage imageNamed:@"bina_s_1.png"];
          UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 107, 154)];
          imageView.image = image2;
  
          UILabel *moneyLbl = [[UILabel alloc] initWithFrame:CGRectMake(55, 80, 40, 20)];
          NSString *moneyStr = [[unitDict objectForKey:@"buyPrice"] description];
          [moneyLbl setText:moneyStr];
          [moneyLbl setFont:[UIFont fontWithName:@"Comic Sans MS" size:15]];
          [moneyLbl setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.0]];
  
          UILabel *minLbl = [[UILabel alloc] initWithFrame:CGRectMake(55, 100, 40, 20)];
          NSString *durationStr = [[unitDict objectForKey:@"name"] description];
          [minLbl setText:durationStr];
          [minLbl setFont:[UIFont fontWithName:@"Comic Sans MS" size:15]];
          [minLbl setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.0]];
  
          UILabel *dpLbl = [[UILabel alloc] initWithFrame:CGRectMake(55, 120, 40, 20)];
          NSString *xpStr = [[unitDict objectForKey:@"xp"] description];
          [dpLbl setText:xpStr];
          [dpLbl setFont:[UIFont fontWithName:@"Comic Sans MS" size:15]];
          [dpLbl setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.0]];
  
          [imageView addSubview:moneyLbl];
          [imageView addSubview:minLbl];
          [imageView addSubview:dpLbl];
  
          UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
          button.frame = CGRectMake(j, 5, 107, 154);
          button.tag = i;
          [button addSubview:imageView];
          [button addTarget:self action:@selector(clickType:) forControlEvents:UIControlEventTouchUpInside];
          [scrollView addSubview:button];
          j += 110;
      }
  
      UILabel *tab1Lbl = [[UILabel alloc] initWithFrame:CGRectMake(19, 7, 70, 20)];
      [tab1Lbl setText:tab1Name];
      [tab1Lbl setFont:[UIFont fontWithName:@"ComicSansMS" size:15]];
      [tab1Lbl setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.0]];
  
      UILabel *alertLbl = [[UILabel alloc] initWithFrame:CGRectMake(340, 5, 85, 20)];
      [alertLbl setText:alertName];
      [alertLbl setFont:[UIFont fontWithName:@"ComicSansMS" size:15]];
      [alertLbl setBackgroundColor:[UIColor colorWithRed:0.92 green:0.59 blue:0.062 alpha:0.0]];
  
      UIImage *image4 = [UIImage imageNamed:@"exit1.png"];
      UIButton *buttonExit = [UIButton buttonWithType:UIButtonTypeCustom];
      buttonExit.frame = CGRectMake(425, 5, 21, 20);
      [buttonExit setImage:image4 forState:UIControlStateNormal];
      [buttonExit addTarget:self action:@selector(exitAlert) forControlEvents:UIControlEventTouchUpInside];
  
      imageTab1 = [UIImage imageNamed:@"panel_btn_active.png"];
      buttonTab1 = [UIButton buttonWithType:UIButtonTypeCustom];
      buttonTab1.frame = CGRectMake(3, 7, 93, 20);
      [buttonTab1 setImage:imageTab1 forState:UIControlStateNormal];
  
      [scrollView setScrollEnabled:YES];
      CGSize size1;
      size1.width = 550;
      size1.height = 75;
      [scrollView setContentSize:size1];
  
  
      [self addSubview:buttonTab1];
      [self addSubview:scrollView];
      [self addSubview:tab1Lbl];
      [self addSubview:alertLbl];
      [self addSubview:buttonExit];
  }
  - (void) clickType:(id) sender{
  
      int myTag = [sender tag];
      NSLog(@"Sender Tag:%i",myTag);
      //[self dismissWithClickedButtonIndex:0 animated:YES];
      /*
       MessageAlertView *alertView = [[MessageAlertView alloc] initWithFrame:self.frame];
       [alertView setImage:[UIImage imageNamed:@"tebrikler_panel.png"]];
  
       [alertView show];
       */
      NSString *str;
      NSDictionary *collectibleDict = [productArray objectAtIndex:myTag];
  
      Communicator *comm = [[Communicator alloc] init];
      [comm buyAndSellCollectible:[location_id intValue] withBuyerId:[player_id intValue] withSellerId:[seller_id intValue] withCollectibleId:[[collectibleDict objectForKey:@"collectible_id"] intValue]];
      NSString *respStr = [NSString stringWithUTF8String:[[comm getRespStr] cStringUsingEncoding:NSUTF8StringEncoding]];
      NSLog(@"%@",respStr);
      NSDictionary *dict = [respStr JSONValue];
  
      NSString *header;
  
      if (![[dict objectForKey:@"msgtype"] isEqualToString:@"error"]) {
          header = [NSString stringWithString:@"Helallll!"];
          [UpdateMe checkLevel:[player_id intValue]];
          [UpdateMe checkMoneyXP:[player_id intValue]];
          [UpdateMe checkBagStatus:[player_id intValue]];
      }
      else{
          header = [NSString stringWithString:@"Errorrrr!"];
      }
  
      str = [NSString stringWithFormat:@"%@",[dict objectForKey:@"msg"]];
  
      [[MainGameScene sharedMySingleton] showMessageAlertView:@"Hello" withMessage2:@"Hello 2" closeAlertView:self];
  }
  - (void) exitAlert{
      [self dismissWithClickedButtonIndex:0 animated:YES];
  }
  - (void) dealloc{
      [unitId release];
      [player_id release];
      [location_id release];
      [seller_id release];
      [unitName release];
      [currentLevel release];
      [productArray release];
      [tab1Name release];
      [alertName release];
      [imageTab1 release];
      [buttonTab1 release];
      [scrollView release];
      [image release];
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>Second AlertView</p>
  
  <pre><code>#import "MessageAlertView.h"
  
  
  @implementation MessageAlertView
  
  @synthesize image;
  @synthesize message1;
  @synthesize message2;
  
  
  // Only override drawRect: if you perform custom drawing.
  // An empty implementation adversely affects performance during animation.
  
  
  - (void)drawRect:(CGRect)rect {
      CGSize size = self.image.size;
      [self.image drawInRect:CGRectMake(0, 0, size.width, size.height)];
  }
  
  - (void) show{
  
      [super show];
      CGSize imageSize = self.image.size;
      self.bounds = CGRectMake(0,0,imageSize.width,imageSize.height);
  
      UILabel *lblMessage1 = [[UILabel alloc] initWithFrame:CGRectMake(15, 1, 70, 30)];
      [lblMessage1 setBackgroundColor:[UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0]];
      [lblMessage1 setText:message1];
  
      UILabel *lblMessage2 = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 200, 30)];
      [lblMessage2 setBackgroundColor:[UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0]];
      [lblMessage2 setText:message2];
  
      UIButton *okButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
      [okButton setBackgroundColor:[UIColor colorWithRed:0.3 green:0.4 blue:0.3 alpha:0]];
      okButton.frame = CGRectMake(133, 103, 80, 25);
      okButton.alpha = 0.1;
      [okButton addTarget:self action:@selector(closeView) forControlEvents:UIControlEventAllTouchEvents];
  
      UIImage *imageClose = [UIImage imageNamed:@"exit1.png"];
      UIButton *buttonClose = [UIButton buttonWithType:UIButtonTypeCustom];
      buttonClose.frame = CGRectMake(320, 4, 21, 20);
      [buttonClose setImage:imageClose forState:UIControlStateNormal];
      [buttonClose addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];  
  
      [self addSubview:okButton];
      [self addSubview:lblMessage1];
      [self addSubview:lblMessage2];
      [self addSubview:buttonClose];
  }
  
  - (void) closeView{
      [self dismissWithClickedButtonIndex:0 animated:YES];
  }
  
  - (void)dealloc {
      [message1 release];
      [message2 release];
      [image release];
      [super dealloc];
  }
  
  
  @end
  </code></pre>
  
  <p>in MainGameScene class i opened second AlertView like that:</p>
  
  <pre><code>-(void) showMessageAlertView:(NSString *)message1 withMessage2:(NSString *)message2 closeAlertView:(UIAlertView *)closeAlertView{
      [closeAlertView dismissWithClickedButtonIndex:0 animated:YES];
  
      MessageAlertView *alertView = [[MessageAlertView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
  
      [alertView setMessage1:message1];
      [alertView setMessage2:message2];
      [alertView setImage:[UIImage imageNamed:@"tebrikler_panel.png"]];
  
      [alertView show];
  }
  </code></pre>