2

我正在使用 Xcode 4.6.1 为 iOS 6 开发。

我有两个视图控制器:viewController1viewController2. 我正在尝试访问以下定义的属性viewController1viewController2但它不起作用):

这是viewController1.m

#import "viewController1.h"

@interface viewController1 ()

@property (nonatomic) MPMoviePlayerController *videoPlayer;

@end

@implementation viewController1

...

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    ...

    self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

    ...

    [self.videoPlayer play];

    ...
}

这是viewController2.m

#import "viewController2.h"
#import "viewController1.h"

@interface viewController2 ()

@end

@implementation viewController2

...

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    viewController1 *thePlayer;
    [thePlayer.videoPlayer pause];

    //This is where I get an error:
    //Property 'videoPlayer' not found on object of type 'viewController1 *'
}

我已经尝试了很多搜索,但我无法弄清楚我做错了什么。任何帮助将不胜感激。

谢谢!:)

4

1 回答 1

3

你已经在你的videoPlayer中定义了你的属性viewController1.m,但是你导入了viewController1.h.

移至。videoPlayer_ viewController1.h不要导入viewController1.m.

于 2013-06-28T15:44:56.757 回答