1

I had used an instance of SDCAlertView in my project to add a UITextView inside an alert to do some facebook posts.It doesnt seem to work properly anymore on ios8.

I had used the following code.

SDCAlertView *alert = [[SDCAlertView alloc] initWithTitle:@"Post To Facebook"
                                                      message:@""
                                                     delegate:nil
                                            cancelButtonTitle:@"Cancel"
                                            otherButtonTitles:@"Post", nil];
    UITextView *textView = [[UITextView alloc] init];
    [textView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [textView setEditable:YES];
    textView.autocorrectionType = UITextAutocorrectionTypeNo;
    [alert.contentView addSubview:textView];
    [textView sdc_pinWidthToWidthOfView:alert.contentView offset:-5];
    [textView sdc_pinHeight:120];
    [textView sdc_horizontallyCenterInSuperview];
    [textView sdc_verticallyCenterInSuperviewWithOffset:SDCAutoLayoutStandardSiblingDistance];
    [alert showWithDismissHandler: ^(NSInteger buttonIndex) {
        NSLog(@"Tapped button: %@", @(buttonIndex));
        if (buttonIndex == 1) {
            NSLog(@"POST %@", textView.text);
        }
        else {
            NSLog(@"Cancelled");
        }
    }];

Result on iOS 7 enter image description here

Result on iOS 8 GM enter image description here

Please let me know if I can fix this issue with some change in my code.

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
Mayank Sharma
  • 63
  • 1
  • 6

1 Answers1

1

I managed to fix this problem by replacing following line

  [textView sdc_verticallyCenterInSuperviewWithOffset:SDCAutoLayoutStandardSiblingDistance];

with the following:

[alert.contentView sdc_pinHeight:120 + SDCAutoLayoutStandardSiblingDistance];
[textView sdc_alignEdgesWithSuperview:UIRectEdgeTop insets:UIEdgeInsetsMake(SDCAutoLayoutStandardSiblingDistance, 0, 0, 0)];

If anyone wants to refer more about this discussion, please visit the following link https://github.com/sberrevoets/SDCAlertView/issues/49

Mayank Sharma
  • 63
  • 1
  • 6