2011-12-12 36 views
3

我有,當我解僱模態視圖一個問題:問題與dismissModalViewController

我有一個的TabBar有五個選項卡。 我在第四個選項卡上顯示模態視圖。 當我解僱它。我去第一個標籤,但我想留在第四個。

要顯示模式我把這個方法,在父控制器:

[self presentModalViewController:controller animated:YES]; 

要隱藏模式我把這個方法,在父控制器:

[self dismissModalViewControllerAnimated:YES]; 

我已經嘗試調用self.tabBarController/self.navigationController方法而不是self方法,但它是同樣的問題。

有人有想法嗎?

編輯:

我打電話在第四個選項卡的控制器中的方法。

這是背景:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init]; 
    imgPicker.allowsEditing = NO; 
    imgPicker.delegate = self; 
    switch (buttonIndex) { 
     case 0: { 
      [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kMobiglissFromPicker]; 
      imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [self presentModalViewController:imgPicker animated:YES]; 
      break; 
     } 
     case 1: { 
      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
       [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kMobiglissFromPicker]; 
       imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
       [self presentModalViewController:imgPicker animated:YES]; 
      }    
      break; 
     } 
    } 
} 

- (void)imagePickerController:(UIImagePickerController *)imgPicker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    UIImage *origin = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 

    UIImage *photo = [origin thumbnailImage:280 
          transparentBorder:0.0 
           cornerRadius:0.0 
         interpolationQuality:kCGInterpolationHigh]; 

    [icon replaceImageWithImage:photo]; 

    [serverProxy updateProfileAvatar:photo]; 
    [self dismissModalViewControllerAnimated:YES]; 
    imgPicker.delegate = nil; 
} 

- (IBAction)editAvatar:(id)sender { 
    NSString *camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ? [WPLanguage get:@"SignupPhotosheetCamera"] : nil; 
    UIActionSheet *photoSheet = [[UIActionSheet alloc] initWithTitle:[WPLanguage get:@"SignupPhotosheetTitle"] 
                  delegate:self 
                cancelButtonTitle:[WPLanguage get:@"CANCEL"] 
               destructiveButtonTitle:nil 
                otherButtonTitles:[WPLanguage get:@"SignupPhotosheetGallery"], camera, nil]; 
    [photoSheet showInView:self.view]; 
} 
+0

請提供這些調用的上下文,而不看你的代碼,不可能知道發生了什麼,我希望你在與第四個選項卡相關聯的視圖控制器內調用presentModalViewController而不是在視圖內控制器顯示標籤欄 – gurooj

+0

如果您的視圖控制r由第四個選項卡提出了這個問題將被解決的模態視圖。或者是這種情況? – JoePasq

+0

@gurooj我在與第四個選項卡關聯的視圖控制器中調用presentModalViewController。 @JoePasq模式視圖已經由第四個選項卡提供,但當我解僱它時,我會轉到第一個選項卡,並且希望保留在第四個 – Baloomba

回答

4

只是一個猜測(你需要添加更多細節):請問您的viewController,它實現了UITabBarDelegate,設置viewWillAppear:(或其他方法所選擇的項目所謂的?

+1

非常感謝這是問題的根源。 – Baloomba