在接口声明中进行条件编译时,Interface Builder 无法识别 IBOutlet

发布于 2024-10-18 14:05:04 字数 1871 浏览 10 评论 0原文

如果我在作为 xib 文件所有者的头文件中添加此条件编译标志,则 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

If I add this conditioning compiling flag in my header file, which is a owner of a xib file, the xib file cannot read the IBOutlet and show as missing. And gives warnings.

In runtime it works fine. Did anybody experience the same problem?

/* 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风情万种。 2024-10-25 14:05:04

您是否尝试过以与编译器等效的方式重组代码,但不太可能混淆 Interface Builder?像这样的事情:

@interface SendMoneyResponseVC : UITableViewController 
    <UINavigationControllerDelegate, 
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
    MFMessageComposeViewControllerDelegate,    
#endif 
    MFMailComposeViewControllerDelegate, 
    UIActionSheetDelegate> 
{ ... }
@end

这样就只有一对 @interface/@end 对。

Have you tried restructuring your code in a way which is equivalent to the compiler, but is less likely to confuse Interface Builder? Something like this:

@interface SendMoneyResponseVC : UITableViewController 
    <UINavigationControllerDelegate, 
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
    MFMessageComposeViewControllerDelegate,    
#endif 
    MFMailComposeViewControllerDelegate, 
    UIActionSheetDelegate> 
{ ... }
@end

This way there will be only one @interface/@end pair.

提赋 2024-10-25 14:05:04

这样做的原因是什么?除非你想使用过时的 SDK 进行编译,否则你应该摆脱它。

Interface Builder 不会预处理您的文件,因此它会看到两个 @interface 和一个 @end。
并且界面构建器无法解析这样的东西。

what is the reason for doing this? Unless you want to compile with an outdated SDK you should get rid of this.

Interface Builder doesn't preprocess your files, so it will see two @interfaces and one @end.
And interface builder can't parse something like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文