Iphone 如何访问在TabBarViewController中选择的ViewController

Iphone 如何访问在TabBarViewController中选择的ViewController,iphone,objective-c,ios,ios5,ios6,Iphone,Objective C,Ios,Ios5,Ios6,我想在单击tabBarItem时加载URL 在targetViewController.m iOS6 Xcode 4.5.1 Making application for iOS5 or later using storyboard @interface targetViewController () @end @implementation targetViewController @synthesize webview; - (void)viewDidLoad { [self

我想在单击tabBarItem时加载URL

在targetViewController.m

iOS6
Xcode 4.5.1
Making application for iOS5 or later
using storyboard
@interface targetViewController ()
@end

@implementation targetViewController
@synthesize webview;

- (void)viewDidLoad
{
    [self loadingMethod:view.webview];
    [super viewDidLoad];
}
(snip)
target2ViewController.m与targetViewController.m几乎相同

在customTabBarViewController.m

iOS6
Xcode 4.5.1
Making application for iOS5 or later
using storyboard
@interface targetViewController ()
@end

@implementation targetViewController
@synthesize webview;

- (void)viewDidLoad
{
    [self loadingMethod:view.webview];
    [super viewDidLoad];
}
(snip)
然而,这并不奏效。 单击TargetViewController的tarBarItem时,将加载目标“2”ViewController的网络视图。 单击目标“2”ViewCOntroller的tabBarItem,将加载TargetViewController的webview


因此,如何访问cliced tabBarItem的ViewController中包含的webview?

使用
UITabBarController
属性
selectedViewController
,它将为您提供所选的
ViewController

在代码中添加[self myLoadingMethod:wwebview];这是错误的,应该是[self myLoadingMethod:webview]。请检查。

如果您点击选项卡栏项目时,会显示viewcontroller的视图,为什么不在其
viewdide:
方法中加载url?很抱歉我的简短解释。我想在点击viewDidApeard和tabBarItem时加载url。t谢谢你的评论。我只是在这个网站上打错了字。我在实际代码中写对了。然后我使用selectedViewController,但我不是ViewController,而是单击tabBarItem时显示的ViewController。如果您觉得答案有帮助,请投赞成票或接受答案。