我提出了一个用根控制器初始化的模态导航栏控制器(这是一个UITableViewController).当我初始化UINavigationBarController以模态方式呈现它时,我还添加了一个"提交"按钮作为右键按钮项.一切正常(使用根视图和模态演示加载)但是,右键没有显示.发布以下代码 -
-(IBAction) presentAddLeaveRequestModally {
AddLeaveRequestViewController *leaveRequestViewController = [[AddLeaveRequestViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:leaveRequestViewController];
UIBarButtonItem *submitButton = [[UIBarButtonItem alloc] initWithTitle:@"Submit"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(submitLeaveRequest)];
navController.navigationItem.rightBarButtonItem = submitButton;
[self.homeTabBarController presentModalViewController:navController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
如果我遗漏了明显的东西,有什么想法?
我还没有在谷歌或堆栈溢出上找到类似的东西......
我想要做的是同时弹出模态视图和前一个视图.例如,查看日历应用.当您在Edit"屏幕上并选择Delete Event"时,您将被带回日历视图.在" Edit"画面,将其模态呈现弹出以及所述的" Event"画面(其中用户被刚刚观看日历事件).我遇到的问题是我知道如何弹出模态视图......但是从同一UIViewController个子类(Edit本例中的"屏幕")中,如何弹出一个非模态的视图?
我正在考虑像往常一样弹出模态视图,然后发布NSNotification到' Event'(例如)屏幕的UIViewController子类并告诉它也弹出该视图.
另一件事是,对于动画,它应该是dismissModalViewControllerAnimated动画(向下滑动)而不是popViewControllerAnimated动画(向左滑动).
谢谢.
另外,寻找比这更好的解决方案,这在我的情况下不起作用(至少没有popViewControllerAnimated)
我有一个按钮,在模态视图中显示我的应用程序,以便人们可以下载并评估应用程序.我得到它用这个代码模态显示.
NSDictionary *appParameters = [NSDictionary dictionaryWithObject:@"607257427"
forKey:SKStoreProductParameterITunesItemIdentifier];
SKStoreProductViewController *productViewController = [[SKStoreProductViewController alloc] init];
[productViewController setDelegate:self];
[productViewController loadProductWithParameters:appParameters
completionBlock:^(BOOL result, NSError *error)
{
}];
[self presentViewController:productViewController
animated:YES
completion:^{
}];
Run Code Online (Sandbox Code Playgroud)
`
这就是它的结果.
问题是取消按钮不起作用,它可能是模拟器或某些非常简单的东西,但我无法弄清楚为什么取消按钮不起作用
我有一个视图控制器,我在另一个视图控制器上模态呈现,顶级VC的背景视图具有模糊效果.当我使用以下代码时,顶视图控制器显示在底部视图控制器上,但顶部控制器隐藏在导航栏后面:
MOSettingsViewController *settingsViewController = [[MOSettingsViewController alloc]init];
settingsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
settingsViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.providesPresentationContextTransitionStyle = YES;
self.definesPresentationContext = YES;
[self presentViewController:settingsViewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
当我删除该行时settingsViewController.modalPresentationStyle...,新的视图控制器出现在导航栏上,但呈现视图控制器变为黑色,并破坏模糊效果.
我如何得到这两个演示文稿的混合,其中呈现视图控制器保持可见并且导航栏位于呈现的视图控制器下?
objective-c modalviewcontroller ios presentviewcontroller uivisualeffectview
我有一个模态segue,它带来一个新的视图控制器,里面有一个视图,和一个透明的背景.
因此,当我最初运行应用程序并按下按钮以启动模式segue时,视图控制器将被引入,它看起来像这样,因为视图控制器具有透明背景:
然而,当我去另一个标签,然后回到我最初的视图控制器时,它看起来像这样: 
我怎样才能使它不显示黑色背景而是显示视图控制器背景,而不是使用SWIFT使标签栏变暗?
目标
ViewControlleriPad 上 modalPresentationStyle - FormSheet 的高度究竟是多少?我写了一行代码来获取 self.view 的高度,如下所示:
println("Height - modalPresentationStyle FormSheet: \(self.view.frame.size.height)")
Run Code Online (Sandbox Code Playgroud)
经过测试,我得到了这两个结果:
ModalViewController 上没有 Formsheet,高度为1024.0
在 modalPresentationStyle 上使用 Formsheet 时,高度为1024.0 ,这是错误的,因为高度应该小于 1024.0
知道它有什么问题吗?我需要使用表单从 self.view.frame.size.height 中获得正确的高度,因为我需要在代码中的某处编写公式。我不需要更改表单的大小。
我的任务是在一些现有的VC中添加新的简单通知模式视图.充其量,我想实现一个在当前视图中显示notificationVC的函数.
有很多类似的问题,但它们不适合我或需要代表,segues等.
谢谢,这就像我想要的:
如何使用我的尺寸在窗口中打开模态 ViewController?
我尝试使用它,但它不起作用
modalViewController?.view.superview?.frame = CGRect(x:162, y: 333, width: 700,height: 700)
//
modalViewController?.view.superview?.center = self.view.center
Run Code Online (Sandbox Code Playgroud)
代码:
let modalViewController = self.storyboard?.instantiateViewController(withIdentifier: "Clipboard") as? ClipboardViewController
modalViewController?.modalPresentationStyle = .overCurrentContext
self.present(modalViewController!, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
例子:
假设我们有两个视图控制器,一个带有标签的父视图控制器和一个带有表格视图的模态呈现子视图控制器。如何使用委托将用户在表视图中的选择传递回父级?
视图控制器1:
var delegate: vc2delegate?
override func viewDidLoad {
super.viewDidLoad()
let label.text = ""
}
Run Code Online (Sandbox Code Playgroud)
视图控制器2:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! Cell
let selections = ["1", "2", "3", "4", "5"]
cell.selections.text = selections[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? Cell {
cell.didSelect(indexPath: indexPath as …Run Code Online (Sandbox Code Playgroud) 学习一些视图控制器基础知识,并专注于如何使用按钮关闭模式。
In my slimmed-down example, I have a two view setup with the initial view and the modal. The first view has a button that successfully pops up the modal. On the modal, there is a button that should dismiss itself.
According to other posts and documentation, I should be able to run simple code attached to the button like this:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func CloseModal(_ sender: Any) {
self.dismiss(animated: true, completion: …Run Code Online (Sandbox Code Playgroud) uiviewcontroller modalviewcontroller swift dismissviewcontroller
ios ×8
swift ×5
objective-c ×2
app-store ×1
delegation ×1
ios6 ×1
iphone ×1
protocols ×1
segue ×1
xcode ×1