Objective C 等同于 self.view.traitCollection.horizontalSizeClass 是什么?

What is the Objective C equivalent of self.view.traitCollection.horizontalSizeClass?

下面 swift 语句的 obj c 代码是什么?

 if (self.view.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClass.Compact)

到目前为止我发现的内容在下面提供,但是当我添加 self.view

时出现错误
    if ([self.view UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassCompact])
    {
        NSLog(@"Compact");
    }

试试这个

if (self.view.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
  // do your stuff
}

希望有用