当我关闭模态视图时遇到问题:
我有一个带有五个选项卡的 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/