iphone - 解雇ModalViewController 的问题

标签 iphone ios5 modalviewcontroller

当我关闭模态视图时遇到问题:

我有一个带有五个选项卡的 tabBar。 我在第四个选项卡上,显示模态视图。 当我驳回它时。我进入第一个选项卡,但我想留在第四个选项卡上。

为了显示模态,我在父 Controller 中调用此方法:

[self presentModalViewController:controller animated:YES];

为了隐藏模式,我在父 Controller 中调用此方法:

[self dismissModalViewControllerAnimated:YES];

我已经尝试调用 self.tabBarController/self.navigationController 方法而不是 self 方法,但这是同样的问题。

有人有想法吗?

编辑:

我调用第四个选项卡 Controller 中的方法。

这是上下文:

- (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];
}

最佳答案

只是猜测(您需要添加更多详细信息):您的 viewController(实现了 UITabBarDelegate)是否在 viewWillAppear:(或其中之一)上设置了所选项目还调用其他方法吗?

关于iphone - 解雇ModalViewController 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8477023/

相关文章:

iphone - 使用 UIPasteboard 在 iOS 中复制功能

iOS Xcode 4.2 主从应用程序模板抛出 NSRangeException

iphone - 如何正确更新Three20?

iphone - 模态视图不会关闭

ios - Swift:要求用户在单击每个停止按钮后输入文本文件名

iphone - 如何防止 CALayer(CATiledLayer 的子层)在缩放后更改其比例?

iphone - 在 Core Data 中使用 Fetch Request 返回什么对象?

iphone - EKEvent 事件标识符返回 null

ios - iPad 模态视图 Controller 在关闭时旋转界面

objective-c - 使用完成按钮以编程方式添加 UINavigationBar