简体   繁体   中英

Xcode 4 control-drag won't create first IBOutlet or IBAction if '@end' is a header file's last line

I created an Xcode 4.5.2 project starting with the Single View Application for iPhone template. After adding a UIButton to MainStoryboard.storyboard, I'm able to control-drag from the button to ViewController.h's code to create a new IBOutlet or IBAction. 额外的线

However, if I remove the last line following @end , which is empty, control-dragging does not offer to create an IBOutlet or IBAction. 没有额外的线

If I add a property to ViewController, then control-dragging offers to create IBOutlets and IBActions again. 现有财产

Edit 1 : As jhilgert00 pointed out, adding curly braces, as if to create a place to declare instance variables, causes Xcode to once again offer to create IBOutlets and IBActions.

Is this an Xcode bug? Or should I not trim the empty line after @end ?

Edit 2 : This issue has been fixed in Xcode 5.

My answer would be that this is a bug that should be filed at https://bugreport.apple.com , I doubt anyone here can give a useful answer. That said it's always a good idea to leave whitespace at the end of a file!

It seems stupid, but opening and closing your curly braces for your @interface seems to fix this issue.

#import <UIKit/UIKit.h>

@interface ViewController : View Controller {

// Drag your IBOutlets here...

}

@end

Screenshot on this answer .

仅供参考,这件事发生在我身上,因为我没有将我的ViewController从通用的改为我试图拖动的那个,这是有道理的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM