在接口声明中进行条件编译时,Interface Builder 无法识别 IBOutlet
如果我在作为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过以与编译器等效的方式重组代码,但不太可能混淆 Interface Builder?像这样的事情:
这样就只有一对
@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:
This way there will be only one
@interface
/@end
pair.这样做的原因是什么?除非你想使用过时的 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.