如果我在头文件中添加这个条件编译标志,则xib文件不能读取IBOutlet并显示为缺失。并给出警告。
在运行时它工作得很好。有没有人遇到过同样的问题?
/* MFMessageComposeViewControllerDelegate is available in iOS 4.0 and later. */
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
@interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate,
MFMailComposeViewControllerDelegate, UIActionSheetDelegate>
#else
@interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate,
MFMailComposeViewControllerDelegate, UIActionSheetDelegate>
#endif
{
IBOutlet UITableView *sendMoneyTableVC;
IBOutlet UITableViewCell *refNumRemittanceCell;
IBOutlet UILabel *refNumLabel, *refNumValueLabel, *refNumInfoLabel;
IBOutlet UITableViewCell *refNumDomesticCell;
IBOutlet UILabel *domesticInfoLabel, *feeAndReferenceLabel;
IBOutlet UITableViewCell *shareRefNumCell;
IBOutlet UIButton *shareRefNumButton;
NSString *referenceNumber, *recipient, *currency, *mtoName;
float amount, fee;
int sendMoneyType;
UIAlertView *smsAlertView;
}
@property (nonatomic, retain) UITableView *sendMoneyTableVC;
@property (nonatomic, retain) UITableViewCell *refNumRemittanceCell;
@property (nonatomic, retain) UILabel *refNumLabel, *refNumValueLabel, *refNumInfoLabel;
@property (nonatomic, retain) UITableViewCell *refNumDomesticCell;
@property (nonatomic, retain) UILabel *domesticInfoLabel, *feeAndReferenceLabel;
@property (nonatomic, retain) UITableViewCell *shareRefNumCell;
@property (nonatomic, retain) UIButton *shareRefNumButton;
@property (nonatomic, retain) NSString *referenceNumber, *recipient, *currency, *mtoName;
@property float amount, fee;
@property int sendMoneyType;
- (IBAction) didPressShareButton;
@end发布于 2011-02-22 23:11:55
这样做的原因是什么?除非你想用过时的SDK编译,否则你应该去掉它。
Interface Builder不会对您的文件进行预处理,因此它将看到两个@Interface和一个@end。
而接口生成器不能解析这样的东西。
发布于 2012-07-13 09:47:14
你有没有尝试过以一种相当于编译器的方式重构你的代码,但又不太可能混淆Interface Builder?如下所示:
@interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
MFMessageComposeViewControllerDelegate,
#endif
MFMailComposeViewControllerDelegate,
UIActionSheetDelegate>
{ ... }
@end这样,将只有一个@interface/@end对。
https://stackoverflow.com/questions/5079444
复制相似问题