我正在尝试使用来自Nick Kuh的书"iPhone App Development"的样式表的教程.样式表头文件抛出:
"期待的类型"
我认为错误通常反映了一个循环问题.但是,在这种情况下,唯一的导入是Foundation.h.(实现文件,顺便说一句,不会抛出任何错误,似乎没问题.)这是完整的头文件.
#import <Foundation/Foundation.h>
typedef enum : int {
IDLabelTypeName = 0,
IDLabelTypeBirthdayDate,
IDLabelTypeDaysUntilBirthday,
IDLabelTypeDaysUntilBirthdaySubText,
IDLabelTypeLarge
}
IDLabelType;
@interface IDStyleSheet : NSObject
+(void)initStyles;
+(void)styleLabel:(UILabel *)label withType:(IDLabelType)labelType;//throws red error
+(void)styleTextView:(UITextView *)textView;//throws red error
+(void)styleRoundCorneredView:(UIView *)view;//throws red error
@end
Run Code Online (Sandbox Code Playgroud)
有人能看出为什么会发生这些错误吗?
UILabel,UITextView...在UIKit框架中定义,因此您必须这样做
#import <UIKit/UIKit.h>
Run Code Online (Sandbox Code Playgroud)
(然后隐含地导入Foundation).您还可以使用更现代的"模块"语法:
@import UIKit;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2930 次 |
| 最近记录: |