2014-09-12 51 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

相關問題