【问题标题】:ViewController UIwebview issueViewController UIwebview 问题
【发布时间】:2016-05-29 07:13:28
【问题描述】:

我是 xcode 的新手,所以我在学习有关在 xcode 7 中将网页放入 ios Objective-c 项目的教程。下面是我使用的代码。 @interface ViewController ()

查看控制器标题

@interface ViewController : UIViewController

IBOutlet UIWebView* webView;

@property (nonatomic, retain) UIWebView *webView;

@end

view controller main
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@synthesize webView;

@end

错误警告是;

1.不能在@interface或@protocol'中声明变量

2.Attribute只能应用于实例变量或属性

两者都适用于以 IBOutlet 开头的第一行

【问题讨论】:

  • 你使用故事板吗?还是您想以编程方式添加 web 视图?

标签: ios objective-c iphone xcode uiwebview


【解决方案1】:

对于实例变量只是缺少{}

@interface ViewController : UIViewController
{
  IBOutlet UIWebView* webView;
}
@property (nonatomic, retain) UIWebView *webView;

@end

但实际上声明可以跳过 例如。

@interface ViewController : UIViewController

@property (nonatomic, retain) IBOutlet UIWebView *webView;

@end

这一行

@synthesize webView;

应该放在@implementation下面以保持一致性,并且也可以跳过

(Xcode 4.4以后编译器会为你生成,但是知道原码就好)

更多关于类: https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/ClassMethod.html

【讨论】:

    猜你喜欢
    • 2011-08-13
    • 2016-01-18
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多