使用未声明的标识符“UISemanticContentAttributeForceLeftToRight”iOS 8.2?

时间:2016-06-15 05:32:23

标签: ios objective-c uialertview

我使用了代码

 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:nil
                                                  otherButtonTitles:@"OK", nil];
[alertView setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[alertView show];

我在第

行收到未使用标识符的错误
[alertView setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];

适用于iOS 9,但不适用于iOS 8.2。如何解决此问题?

1 个答案:

答案 0 :(得分:1)

//嗨,semanticContentAttribute属性只能从ios 9.0获得,你需要检查操作系统版本或尝试这样

if ([alertView respondsToSelector:NSSelectorFromString(setSemanticContentAttribute:)]) {
   [alertView setValue:[NSNumber numberWithInt:3] forKey:@"semanticContentAttribute"];
}