我只是为我提供了这个错误报告…活动视图控制器突然出现这种奇怪的狭窄形状,无论我是在实际的手机还是视图控制器上.
这种情况发生在一些普通的香草代码中,这些代码几个月没有被触及:
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[message] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:nil];
怎么可能出错?我甚至无法想到从哪里开始排除故障.
解决方法
在某些情况下可能会发生.试试这个
NSArray *Items = [NSArray arrayWithObjects: @"Checking Test App",nil]; UIActivityViewController *activity=[[UIActivityViewController alloc]initWithActivityItems:Items applicationActivities:nil]; [self presentViewController:activity animated:YES completion:nil];
要么
NSString *string = NSLocalizedString(@"shareString",nil); UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[string] applicationActivities:nil]; [activityViewController setCompletionWithItemsHandler: ^(NSString *activityType,BOOL completed,NSArray *returnedItems,NSError *error) { if ( completed ) { NSLog(@"sharing complete"); } else { NSLog(@"cancelled"); } }]; [self presentViewController:activityViewController animated:YES completion:^{ }];