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.