0

我正在尝试创建一个可以在其中导入文件的应用程序。它设置在 iOS 部署目标为 5.1 的故事板上。标签栏已经设置好故事板。

我想更改视图,以便当用户有他们希望导入的文件(例如从电子邮件)时,应用程序将视图切换到选项卡栏上的另一个页面。

当我尝试viewDidLoad在选项卡栏的初始页面上进行设置时,它不起作用,因为该功能没有被读取。

我应该怎么办?

我应该更改applicationDidBecomeActive方法中的 AppDelegate 吗?如果是这样,是在方法applicationDidBecomeActive之前还是之后读取application:application openURL:url sourceApplication:sourceApplication annotation:annotation

我应该更改初始页面的代码吗?如果是这样,当我导入文件时会调用什么?

这是一些代码:

#import "AppDelegate.h"

...

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if (url != nil && [url isFileURL]) {
        [self handleOpenURL:url];        
    }

    return YES;
}

-(void)handleOpenURL:(NSURL *)url {
    NSError *outError;
    NSString *fileString = [NSString stringWithContentsOfURL:url
                                                    encoding:NSASCIIStringEncoding
                                                       error:&outError];
    file = fileString;
}
4

1 回答 1

0

在打开文件方法中执行页面更改调用

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
//Initiates the segue with the specified identifier from the view controller’s storyboard file.
于 2012-11-09T00:36:50.273 回答