我正在使用completionWithItemsHandler来确定selectedItems是否已发布到Tumblr。我想提出一个'成功'!如果帖子已完成则发出警报但即使用户无法登录Tumblr,completionHandler也会返回“已完成”。也就是说,用户完成选择项目,打开活动视图和选择Tumblr - >的步骤。这将打开Tumblr应用程序并要求登录。如果用户按下“取消”并返回到我的应用程序,则completionHandler表示活动已“完成”。有没有办法确定帖子是否成功?有没有办法测试用户是否能够登录应用程序?当存在这些类型的问题时,有关处理“成功”警报的任何建议吗? 这是完成处理程序
activityController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *error){
if (error)
{
//NSError *error;
alertController = [UIAlertController alertControllerWithTitle:@"Error" message:@"Error sharing items" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *errorAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
NSLog(@"Error sharing items: %@", error);
}];
[alertController addAction:errorAction];
[self presentViewController:alertController animated:YES completion:nil];
}
else if (completed)
{
[self.activityIndicator stopAnimating];
if ([self.giftID isEqualToString:@"general"]||[self.giftEntity.giftThanked isEqualToString:@"YES"])
{
alertController = [UIAlertController alertControllerWithTitle:alertTitle message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
// NSLog(@"OK action");
[self dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
if (![self.giftID isEqualToString:@"general"]&&[self.giftEntity.giftThanked isEqualToString:@"NO"])
{
alertController = [UIAlertController alertControllerWithTitle:alertTitle message:@"Mark gift as 'Thanked'?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", @"yes action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
self.giftEntity.giftThanked = @"YES";
[self.giftBusObj saveEntities];
[self dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"NO", @"no action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
self.giftEntity.giftThanked = @"NO";
[self.giftBusObj saveEntities];
[self dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:noAction];
[alertController addAction:yesAction];
[self presentViewController:alertController animated:YES completion:nil];
}
//Deselect all items in stvc
self.textShare = 0;
self.cardButton.selected = NO;
self.textImageBackground.backgroundColor = [UIColor clearColor];
self.cardImageBackground.backgroundColor = [UIColor clearColor];
[spcvc selectPhotosNone];
[self viewDidLoad];
}
else
{
[self dismissViewControllerAnimated:YES completion:nil];
NSLog(@"activity controller - not 'completed' nor 'error'" );
}
};