我按照这里的步骤操作:http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/
Here are the bare bones steps to turning a web app into a native app:
- Open XCode.
- Create a new "View-based Application" iPhone project.
- Move the files for your web app into the Resources folder in XCode, but strip out the cache manifest. (You don't want the manifest screwing things up, since everything is now local.)
- Create a new instance variable, webView, inside the @interface ViewController header file: IBOutlet UIWebView* webView ; // IBOutlet means it's visible to Interface Builder.
- and create a property: @property (nonatomic, retain) UIWebView *webView;
这是我目前所拥有的(ViewController.h):
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
IBOutlet UIWebView* webView;
@property (nonatomic, retain) UIWebView *webView;
@end
但是在第 4 步,我的 ViewController 头文件中出现了两个错误:
"cannot declare variable inside @interface or @protocol"
and
"iboutlet attribute can only be applied to instance variables or properties"
那么我哪里做错了,还是那个网站教程错了?
注意:我下载了他为 iPhone 准备的示例项目并且它有效,但我正在按照教程进行操作,以便制作 iPad 版本。
我在 XCode 4 中,错误显示我使用的是 iOS 5 还是 iOS 4.3 似乎没有什么区别。
最佳答案
你少了几个花括号:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@end
关于objective-c - 为什么在尝试将 UIWebView 添加到此 ViewController 头文件时会出现这些错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7599221/