0

I have subclassed UIView to contain basically a UIPickerView and a UIToolbar.

When the user selects a particular row in the picker I will then add a UIImageView over the picker. However this image is not visible when I have animated my UIView to slide up the screen. If I don't animate the UIView then it will display properly.

I'm displaying the UIImageView like this (in the UIView):

- (void)showMailSetupPopover {

    if (self.popoverMailSetupImageView == nil) {

        UIImageView *popoverMailSetupImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"popover-mail-setup-addreminder"]];
        popoverMailSetupImageView.alpha = 0.0;
        popoverMailSetupImageView.frame = CGRectMake(8, self.frame.origin.y + 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height);
        self.popoverMailSetupImageView = popoverMailSetupImageView;
    }

    [self addSubview:self.popoverMailSetupImageView];

    [UIView animateWithDuration:0.5 animations:^{

        self.popoverMailSetupImageView.alpha = 1.0;

    } completion:^(BOOL finished) {}];
}

This is how I add theUIView to self.view:

RMMessageTypePickerView *messageTypePickerView = [[RMMessageTypePickerView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height, 320, 260) reminderMessageType:RMReminderMessageTypeText delegate:self];

self.messageTypePickerView = messageTypePickerView;

[self.view addSubview:self.messageTypePickerView];

[UIView animateWithDuration:0.2 animations:^{

    self.messageTypePickerView.frame = messageTypePickerViewTargetFrame;
    self.addReminderTableView.frame = addReminderTableViewTargetFrame;

} completion:^(BOOL finished) {

    if (firstShow) {

        [self processSelectedMessageTypeRow:RMReminderMessageTypeText];
    }
}];
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • [self.view addSubview:self.messageTypePickerView]; -> put this into the animation completion block. – Petar Mar 07 '13 at 10:38
  • @pe60t0 i think you are completely wrong. if he would add the view in the completion block, then the animated movement of the view wouldn't be possible – David Ben Ari Mar 07 '13 at 11:21
  • @Peter Warbo, can you add the code where you call - (void)showMailSetupPopover – David Ben Ari Mar 07 '13 at 11:25

1 Answers1

0

Found out the issue,

Replaced

popoverMailSetupImageView.frame = CGRectMake(8, self.frame.origin.y + 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height);

with

popoverMailSetupImageView.frame = CGRectMake(8, 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height);

self.frame.origin.y is not needed.

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193