4

我正在为警报提示创建 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 确实有效。

我将如何解决这个问题?

4

1 回答 1

0

所以你试图返回[promptTextBox text]调用JavaScript?

这个怎么样:

NSLog(@"%@", [promptTextBox text]); // output to log   
[task success:[promptTextBox text]]; // output call back

...还是我错过了重点?

于 2013-02-28T17:26:12.113 回答