我正在为警报提示创建 trigger.io 插件。尝试从警报提示返回数据。这是我的代码:
// Prompt
+ (void)show_prompt:(ForgeTask*)task{
// Create the alert
UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
UITextField *promptTextBox = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
[promptTextBox setTag:30050]; // set tag to find the text box
[promptTextBox setBackgroundColor:[UIColor whiteColor]];
[prompt addSubview:promptTextBox]; // add it to the alert
[prompt show]; //show alert
}
// Call back
+ (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex task:(ForgeTask*)task
{
// Grab the reply from text box
UITextField* promptTextBox = (UITextField*)[alertView viewWithTag:30050];
NSLog(@"%@", [promptTextBox text]); // output to log
[task success:nil]; // output call back
}
当我尝试执行[task success:nil];时,上述内容不起作用 并包括task:(ForgeTask*)task回调停止工作。
但是没有[task success:nil]; & task:(ForgeTask*)task NSLog 确实有效。
我将如何解决这个问题?