iphonepresentModalViewController

标签 iphone

我有一个应用程序,其中 UIViewController 附加在 UIWindow 上。 在UIViewController的 View 上,我添加了一个按钮和一个大小为100x80的uiview_1。 此 uiview_1 包含另一个 uiview_2 作为相同大小的 subview ,并且此 uiview_2 在运行时包含 UIImageViewUIlable (UIImageViewUIlable 已启用用户交互)

现在在触摸/单击UIImageView时,我想使用presentModalViewController显示一个新 View ,问题是显示 View 并使用导航上的后退按钮酒吧我来到上一个/主屏幕。 问题出现在图片中,现在我无法触摸按钮或 UIImageView。 两者都没有响应,但应用程序没有崩溃,也没有卡住。

这有什么问题吗?

请帮忙...

----- 编辑:

首先采用的方法:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
UIViewController *pushController = [[UIViewController alloc] init];
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
[win addSubview:pushController.view];
[pushController presentModalViewController:viewNavController animated:YES];

在 swvController 中,我有一个后退按钮,单击时会调用解雇 Model View Controller >> 结果是主屏幕 ctrls 没有响应触摸 – 桑迪 3 小时前

第二种方法:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
UIViewController *pushController = [[UIViewController alloc] init];
[self addSubview:pushController.view];
[pushController presentModalViewController:viewNavController animated:YES];

在 swvController 中,我有一个后退按钮,点击后会调用 DismissModelViewController >> 结果是 swvController 导航栏上的后退按钮没有响应 – 桑迪 3 小时前

第三种方法:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
SampleAppAppDelegate *appdel = [[UIApplication sharedApplication] delegate]; [appdel.viewController presentModalViewController:viewNavController animated:YES];

>> 结果工作正常,但问题是我不想使用 SampleAppAppDelegate,我想将我的小 Uiview (100x80) 作为其他人的 ctrl,我的 ctrl 将无法获取他们的 AppDelegate应用程序在运行时。 – 桑迪 3 小时前

最佳答案

当您想要呈现模态视图 Controller 时调用此方法:

- (IBAction)showInfo {    
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];
}

将此方法添加到您自己的方法中:

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
    [self dismissModalViewControllerAnimated:YES];
}

使用工具栏或其他按钮并将其连接到模态视图 Controller 中的此方法:

- (IBAction)done {
    [self.delegate flipsideViewControllerDidFinish:self];   
}

所有代码均来自 Apple。

关于iphonepresentModalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1592709/

相关文章:

iOS Push Segue(以编程方式)有时会卡住但不会崩溃

iphone - 设置iphone View Controller 的 View

iphone - 在iOS 6中是绝对不能使用Google map 的吗?

iphone - 在iPhone中长时间在后台运行应用程序

iphone - 在 UIImage (或其衍生物)中,如何用一种颜色替换另一种颜色?

iphone - jQuery 检测移动 Safari/iOS 上的页面底部

iOS - iOS 10.2 更新后 HLS 视频不再在 WebView 中播放

IOS 如何传递变量 valet scheduledTimerWithTimeInterval

iphone - 改变 uidraw 中的颜色变化

iphone - 在 UIWebView 中打开弹出链接,可能吗?