سؤال

So I've got a UIActivityViewController that takes up half the screen when my app runs, what happens is when I click the half it doesn't take up then it'll disappear and my original blank ViewController appears.

Is it possible to permanently keep the UIActivityView up until the user clicks on one of the sharing options (such as Facebook, or Mail)? Otherwise I'll just work around it.

I load the ActivityView with:

-(void)viewDidAppear:(BOOL)animated{

    UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:@[@""] applicationActivities:nil]; 

    [self presentViewController:controller animated:YES completion:nil];
}
هل كانت مفيدة؟

المحلول

Yes, it is possible, you can try something like

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAViewController) name:@"showAViewController" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dissmissAViewController) name:@"dissmissAViewController" object:nil];
}

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter]removeObserver:self name:@"showAViewController" object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self name:@"dissmissAViewController" object:nil];
}

-(void)showAViewController{
self.view.userInteractionEnabled=NO;
}

-(void)dissmissAViewController{
self.view.userInteractionEnabled=YES;
}

When you are showing a view controller on top of another view controller just call

[[NSNotificationCenter defaultCenter] postNotificationName:@"showAViewController" object:nil];

After you dismiss it or remove it, just call:-

[[NSNotificationCenter defaultCenter] postNotificationName:@"dissmissAViewController" object:nil];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top