标签: modalviewcontroller

显示连续modalViews的正确方法

我有两个视图需要以模态方式显示,一个接一个.如果我们连续解雇和显示,这不起作用,如下所示:

[rootController dismissModalViewControllerAnimated: YES];
[rootController presentModalViewController: psvc animated: YES];
Run Code Online (Sandbox Code Playgroud)

第二个模态视图根本没有显示出来.

我见过一个像这样的修复:

[rootController dismissModalViewControllerAnimated: YES];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[self performSelector: @selector(seekModal) withObject: nil afterDelay: 0.5];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
Run Code Online (Sandbox Code Playgroud)

问题是这不会一直有效(所需的延迟有时是优越的).

另一个可能的解决方法是消除动画:

[rootController dismissModalViewControllerAnimated: NO];
[rootController presentModalViewController: psvc animated: YES];
Run Code Online (Sandbox Code Playgroud)

但我真的很想保留动画,以保持第一个模态不受影响的感觉.有什么建议?

iphone animated dismiss modalviewcontroller

9
推荐指数
1
解决办法
5679
查看次数

为什么Apple建议以编程方式创建模态导航控制器?

"当以模态方式呈现导航控制器时,以编程方式创建和配置导航控制器对象通常更简单.虽然您也可以使用Interface Builder来执行此操作,但通常不建议这样做." 事实上,因为我的导航控制器很简单,我宁愿在IB中自定义视图!

iphone objective-c interface-builder uinavigationcontroller modalviewcontroller

9
推荐指数
1
解决办法
582
查看次数

iOS:预览文档时是否可以自定义"打开..."菜单?

我希望利用无论是UIDocumentInteractionControllerQLPreviewController预览我的应用程序中都PDF和图片.我想知道是否有任何下面的自定义是可能的(我已经搜索了文档而没有任何运气).

  • 完全删除"打开..."菜单(例如,用户可以预览图像但不能将其导出到其他应用程序)

  • 让"打开..."菜单打开一个文件,而不是正在预览的文件(例如预览是PDF文档,但"打开..."菜单实际上会导出一个ePub文件)

UIDocumentInteractionControllerDelegate有一个documentInteractionController:canPerformAction:看起来类似于我正在寻找的方法,但文档表明,copy:并且print:是唯一受支持的选择器.

(另外,不那么重要,但有可能修改UIModalTransitionStyleUIModalPresentationStyle任一个的UIDocumentInteractionController还是QLPreviewController?既然QLPreviewController是的一个子类UIViewController,我想我可以设置modalTransitionStyle和modalPresentationStyle性能,但是这并没有产生预期的结果.)

iphone cocoa-touch uiviewcontroller modalviewcontroller ios

8
推荐指数
1
解决办法
4534
查看次数

在解除模态并在内存警告后从后台返回后,iOS 5选项卡的空白屏幕

  1. 使用iOS 5模拟器或设备运行带有标签的应用
  2. 打开一个模态对话框
  3. 模拟内存警告(对于设备转到一些内存密集型应用程序)
  4. 切换到另一个应用程序(如果您还没有这样做)
  5. 回到应用程序
  6. 关闭对话框

您将看到一个空白屏幕(窗口).测试项目以演示此错误/问题:http://github.com/chetanpungaliya/iOS-5-TestModal

didreceivememorywarning modalviewcontroller ios ios5

8
推荐指数
1
解决办法
1071
查看次数

dismissviewcontrolleranimated完成没有在uiimagepickercontroller上调用完成

这是我的代码:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


    [picker dismissViewControllerAnimated:YES completion:^(void){
        NSLog(@"Test");

    }];
}
Run Code Online (Sandbox Code Playgroud)

它取消了模态视图控制器,但不调用完成参数.难道我做错了什么?

iphone objective-c modalviewcontroller ios

8
推荐指数
1
解决办法
2万
查看次数

模态视图控制器强制iOS 6中的横向方向

我有一个以纵向模式呈现的UITabBarController.在其中一个选项卡上,我有一个按钮,以模态方式显示UIViewController(一个简单的故事板segue执行操作).

我希望这个模态视图以横向模式显示,但我不能让它自动转动.

我在模态视图控制器中有这个

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Run Code Online (Sandbox Code Playgroud)

我已将landscapeLeft添加到.plist支持的方向(虽然这也允许TabBar旋转,我不想要)

我还将它添加到模态视图的ViewDidLoad中

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
Run Code Online (Sandbox Code Playgroud)

但我不能让它自己旋转.

谢谢

编辑----

似乎应该是自动旋转甚至没有被调用!

此外,我正在尝试检测方向,下面的代码总是显示2,无论方向如何!

if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait) {
        NSLog(@"1");
        self.hostView.frame = CGRectMake(0, 60, 200, 255);
    } else {
        NSLog(@"2");
        self.hostView.frame = CGRectMake(0, 45, 480, 255);
    }
Run Code Online (Sandbox Code Playgroud)

编辑2 ---

我的错.我想我应该提到我正在使用iOS 6.显示器在iOS 5上自动旋转.不推荐使用shouldAutorotateToInterfaceOrientation,所以我需要阅读新方法.

xcode cocoa-touch uiinterfaceorientation modalviewcontroller ios

8
推荐指数
2
解决办法
1万
查看次数

iPad上UIDocumentInteractionController的可能错误:presentPreviewAnimated没有被推入导航堆栈

仅限iPad:UIDocumentInteractionController presentPreviewAnimated未被推入导航堆栈,即使从documentInteractionControllerViewControllerForPreview返回导航控制器时也只显示模态

大家好

我想知道是否有人可以在这里帮助我,我相信这可能是一个只与iPad有关的错误(它可以在iPhone上运行),但在我提交之前需要确认.

为了让UIDocumentInteractionController在导航控制器中工作,我按照推荐的方法返回导航控制器表单documentInteractionControllerViewControllerForPreview,但它不起作用.

我甚至尝试将Apple提供的UIDocumentInteractionController代码示例升级到iPad,果然,即使我从documentInteractionControllerViewControllerForPreview返回导航控制器,文档交互控制器也会以模态显示.但是对于iPhone来说,它确实会被推入导航堆栈.

我试图设计一个基于splitviewcontroller的应用程序,使用文档交互控制器读取PDF文件,这样PDF将显示在DetailViewController中,但这仅适用于QLPreviewController(不是Doc交互控制器).

有没有人有这个问题?我把下面的示例代码放在我看到的图像中:

我正在使用iOS 6.0 SDK.

static NSString* documents2[] =
{
    @"PDF Document.pdf"
};

@implementation WhizTBViewController

@synthesize documentURLs, docInteractionController;

#pragma mark -
#pragma mark View Controller

- (void)setupDocumentControllerWithURL:(NSURL *)url
{
    if (self.docInteractionController == nil)
    {
        self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
        self.docInteractionController.delegate = self;
    }
    else
    {
        self.docInteractionController.URL = url;
    }
}


- (void)previewDocument {
    // three ways to present a preview:
    // 1. Don't implement this method and simply attach the canned gestureRecognizers to the cell …
Run Code Online (Sandbox Code Playgroud)

controller document interaction modalviewcontroller ios6

8
推荐指数
1
解决办法
1215
查看次数

是对PRESViewController的ARC内存管理:动画:完成:在iOS 6.x中被破坏了吗?

我的视图控制器通过该presentViewController:animated:completion:方法呈现视图.视图很好.

然后我忽略了这个视图并重新呈现它并得到以下崩溃:

*** -[WebBrowser isKindOfClass:]: message sent to deallocated instance 0x1f640ac0
Run Code Online (Sandbox Code Playgroud)

我的代码使用的是ARC.这是我的WebBrowser类的代码,一个简单的嵌入式浏览器.

WebBrowser.h:

@interface WebBrowser : ITViewController <UIWebViewDelegate, UIAlertViewDelegate>

@property (nonatomic, strong) NSString *URL;
@property (nonatomic, weak) IBOutlet UIWebView *webView;
@property (nonatomic, weak) IBOutlet UIActivityIndicatorView *spinner;

- (id)initWithURL:(NSString *)URL;
- (IBAction)dismissView:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

WebBrowser.m:

@implementation WebBrowser

- (id)initWithURL:(NSString *)URL_ {
    self = [super initWithNibName:@"MyNib" bundle:nil];
    if (self) {
        self.URL = URL_;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.webView.delegate = self;

    if (self.URL) {
        [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL …
Run Code Online (Sandbox Code Playgroud)

modalviewcontroller ios ios5 ios6

8
推荐指数
1
解决办法
2299
查看次数

保留工具/标签栏时的部分卷曲模态过渡样式

有没有办法提出一个模态视图控制器,不包括UITabBarController的标签栏?

具体来说,我想使用UIModalTransitionStylePartialCurl,但保留底部栏,一个iPhone映射应用程序.

iphone uitabbarcontroller modalviewcontroller

7
推荐指数
1
解决办法
2336
查看次数

交互式解雇模态时出现故障

我们遇到了这个问题,当实现模态视图控制器的交互式解雇(拖动模式向下应该忽略它)时UIPercentDrivenInteractiveTransition.

建立:

  1. 用至少一个按钮UIViewController嵌入的设置UINavigationControllerUINavigationBar
  2. 模态地呈现另一个UIViewController嵌入在UINavigationController中的至少一个按钮UINavigationBar
  3. UIPanGestureRecognizer在modaly上设置UINavigationController驱动器UIPercentDrivenInteractiveTransition
  4. 拖动模态向下"按住"它 UINavigationBar

问题:

  • 在慢慢向下拖动时,动画故障导致模态视图上下跳跃

  • 毛刺只出现在:

    1. 两者UINavigationBar都至少有一个按钮
    2. 你通过点"按住"模态 UINavigationBar

最小的例子可以从github repo下载.

有没有人遇到过这样的问题?有没有解决方法?我们的设置有一些缺陷吗?

更新

问题已经模拟了与iPhone 5的模拟器上面跑项目iOS 9.3,OSX 10.11.4与Xcode的编译7.3.1.

更新2

进一步调查显示,该问题可能不在动画中:由于某些原因,在给定的设置pan.translationInView(view)中返回意外值,导致动画跳转.

部分解决方法

根据弗拉基米尔的想法,我们通过重写hitTest方法部分解决了这个问题UINavigationBar:

class DraggableNavigationBar: UINavigationBar {

    override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
        guard let view = super.hitTest(point, withEvent: event) else { return …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller modalviewcontroller ios

7
推荐指数
1
解决办法
644
查看次数