Note that there are some explanatory texts on larger screens.

plurals
  1. POUIView animation causes a UIButton to jump
    text
    copied!<p>UI is programmatically generated in my app. I have few <code>buttons</code> and <code>texboxes</code> in the UI. I have developed a custom <code>uidatapicker</code> object, which pops up from the top and animates to the middle of the screen. When <code>uidatapicker</code> pops up I draw another <code>UIView</code>(called helper view) with the size of the screen so all other <code>uiobject</code>s in the screen except <code>uidatepicker</code> become disabled. But when the <code>UIDatePicker</code> is animating a button in the UI jumps to another location. Also I have three buttons in my UI. It happens with only one button(one UIButon in the UIView). Other two buttons are ok. Also there is no significant difference between those buttons except the button text. </p> <ul> <li>I removed the earlier described view(helper view), but still the problem is occurring.</li> <li>I need to know why this is occurring how to prevent it.</li> <li>Also I have lot of other pages which works fine.</li> </ul> <p>The code</p> <pre><code>-(void)openEditDateTime:(UIDatePickerMode) mode { if ([clientView viewWithTag:9]) { [self cancelPressed]; } CGRect toolbarTargetFrame = CGRectMake((clientView.frame.size.width/2)-160, (clientView.frame.size.height/2)+91, 320, 44); CGRect datePickerTargetFrame = CGRectMake((clientView.frame.size.width/2)-160, (clientView.frame.size.height/2)-125, 320, 216); backgroundView = [[UIView alloc] initWithFrame:clientView.bounds]; backgroundView.alpha = 0; backgroundView.backgroundColor = [UIColor blackColor]; backgroundView.tag = 9; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelPressed:)]; [backgroundView addGestureRecognizer:tapGesture]; [clientView addSubview:backgroundView]; [self bringToFront:backgroundView]; datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, self.bounds.size.height+44, 320, 216)]; datePicker.tag = 10; datePicker.datePickerMode = mode; [clientView addSubview:datePicker]; [clientView bringSubviewToFront:datePicker]; [datePicker becomeFirstResponder]; [self bringToFront:datePicker]; if(date != nil){ datePicker.date = date; } toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.bounds.size.height, 320, 44)]; toolBar.tag = 11; toolBar.barStyle = UIBarStyleBlackTranslucent; UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(donePressed:)]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelPressed:)]; [toolBar setItems:[NSArray arrayWithObjects:spacer, doneButton, cancelButton, nil]]; [clientView addSubview:toolBar]; [clientView bringSubviewToFront:toolBar]; [UIView beginAnimations:@"MoveIn" context:nil]; toolBar.frame = toolbarTargetFrame; datePicker.frame = datePickerTargetFrame; backgroundView.alpha = 0.5; [UIView commitAnimations]; } </code></pre> <p><br> - <code>clientView</code> is a <code>UIScrollView</code>.<br> - <code>backgroundView</code> is the helper view described earlier.<br> <br> This is how I add buttons. <br>I wil put only a part of the button rendering code as putting all the code is unnecessary and it has lot other dependencies as well.<br></p> <pre><code>-(RenderedElement*)renderElement:(NSObject*)element:(ParentView*)parent:(PageView*)page:(Page*)modelPage:(RenderedElement*)parentRenderedElement { UIButton *buttonView = nil; Button *templateElement = nil; buttonView = [UIButton buttonWithType:UIButtonTypeCustom]; [buttonView setLineBreakMode:UILineBreakModeWordWrap]; [buttonView addTarget:parent action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [parent addSubview:buttonView]; } </code></pre> <p><br><strong>UPDATE</strong><br> When I change the order of rendering and if I render the buttons first the jumping effect is not happening. The UI works fine. It temporally solves the problem. But I want find the reason and have a better solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload