UIActivityViewController not dismissing

徘徊边缘 提交于 2019-12-08 06:11:27

问题


I'm trying to add a custom UIActivity to a UIActivityController. When I click on the item, it presents the view controller I want it to, but when I finish with that view controller, the original UIActivityViewController is still there. My question is, how and where do I dismiss the activity view controller? This is the code in my custom UIActivity.

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems{
    self.activityTitle = @"Text Editor";
    self.activityType = @"TextEdit";
    self.activityImage = [UIImage imageNamed:@"Icon.png"];
    if (activityItems) return YES;
    else return NO;
}

- (void)prepareWithActivityItems:(NSArray *)activityItems{
    for (NSString *path in activityItems) {
        if ([path lastPathComponent]) {
            self.file = path;
        }
    }
}

- (UIViewController *)activityViewController{
    ACTextEditController *actec = [[ACTextEditController alloc] initWithFile:_file];
    return actec;
}

EDIT

I've tried doing this, and I know it is called because I tried logging something in it and it was called

- (void)activityDidFinish:(BOOL)completed{
    if (completed) {
        [self.activityViewController dismissViewControllerAnimated:YES completion:nil];
    }
}

however, it's still there when the view controller dismisses. Why?


回答1:


Here's a working example:

http://www.apeth.com/iOSBook/ch26.html#_activity_view

Notice that we end up by calling activityDidFinish:. That is what tears down the original interface. It may be that that is the step you are omitting. If not, just compare what you're doing with what I'm doing, since what I'm doing works (on iPhone).



来源:https://stackoverflow.com/questions/16227093/uiactivityviewcontroller-not-dismissing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!