Question

Is the following valid on iOS 6 using Xcode 5 and the latest compiler?

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

UIButtonTypeSystem seems to resolve to the same thing as UIButtonTypeRoundedRect on iOS 6 as well as iOS 7 if I'm not mistaken but I may be misreading this.

typedef NS_ENUM(NSInteger, UIButtonType) {
    UIButtonTypeCustom = 0,                         // no button type
    UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),  // standard system button

    UIButtonTypeDetailDisclosure,
    UIButtonTypeInfoLight,
    UIButtonTypeInfoDark,
    UIButtonTypeContactAdd,

    UIButtonTypeRoundedRect = UIButtonTypeSystem,   // Deprecated, use UIButtonTypeSystem instead
};
Était-ce utile?

La solution

If you need to support iOS 6 then simply use UIButtonTypeRoundedRect instead of UIButtonTypeSystem. Then it will work under both iOS 6 and 7.

Autres conseils

The docs are your friend. Searching under UIButtonTypeSystem, we find:

UIButtonTypeSystem A system style button, such as those shown in navigation bars and toolbars. Available in iOS 7.0 and later.

So no, UIButtonTypeSystem is new in iOS 7. Results for older OS versions will be undefined.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top