0

私は今ちょっと必死です:/4つのアイテムを持つタブバーコントローラーを持っています。4.タブには、PDFのリストを表示するwebViewを含めました。webViewでPDFを開くと、リンクを使用してメインのwebViewに戻る方法がありません。4. TabBarを再度クリックしてビューをリロードする方法はありますか?3.タブバーから4.タブバーに変更すると、機能します(viewWillAppear)。

ここに画像の説明を入力してください

誰かが私に、次の方法がうまくいくはずだと言った:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if ([viewController isKindOfClass:[UIColor class]]) {
    //Try this if you're pushing the webView in another ViewController
    [viewController.navigationController popToRootViewControllerAnimated:YES];
    //or access to your webView and call goBack();
}

}

しかし実際には、そのメソッドをどのファイルに挿入する必要があるのか​​わかりません。(印刷画面を参照)

助けてくれてありがとう!

4

1 に答える 1

2
  1. サブクラスUITabBarController

1.1。Cmd + Nを使用して、NSObjectクラスの新しいインスタンスを作成し、TabBarControllerという名前を付けます。

1.2。それが読むようにTabBarController.h置き換えるNSObject@interface TabBarController : UITabBarController <UITabBarControllerDelegate>

1.3。これをTabBarController.m追加します:

- (id) init
{
  self = [super init];
  if (self) 
  {
    self.delegate = self;
  }
  return self;
}

1.4。この

- (void)tabBarController:(UITabBarController *)tabBarController 
    didSelectViewController:(UIViewController *)viewController
{
  // Is this the view controller type you are interested in?
  if ([viewController isKindOfClass:[MehrViewController class]])
  {
    // call appropriate method on the class, e.g. updateView or reloadView
    [(MehrViewController *) viewController updateView];
  }
}

1.5。IB、検査で、タブバーコントローラーのクラスを(ではなく)に変更します。 TabBarControllerUITabBarController

1.6。MehrViewController.hまた、に含める必要がありますTabBarController.m


編集

MehrViewController.m内(webViewがあると仮定して、質問に投稿したとおり)

// An example of implementing reloadView
    - (void)reloadView {
       [self.webView reload];
    }
于 2012-03-15T20:14:04.433 に答える