2014-09-12 45 views
1

我在我的项目中使用了SDCAlertView的一个实例,在alert中添加一个UITextView来做一些facebook posts.It似乎不再适用于ios8。是否在iOS 8上正确添加子视图到SDCAlertView?

我已经使用了下面的代码。在iOS 7在iOS 8 GM enter image description here

结果

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"); 
     } 
    }]; 

结果 enter image description here

请让我知道如果我能在我的代码一些变化解决这个问题。

回答

1

我设法用下列替换以下行

[textView sdc_verticallyCenterInSuperviewWithOffset:SDCAutoLayoutStandardSiblingDistance]; 

来解决这个问题:

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

如果有人想引用这个讨论更多信息,请访问以下链接 https://github.com/sberrevoets/SDCAlertView/issues/49

相关问题