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を含めると、コールバックが機能しなくなります。

しかし、[タスクの成功:nil]なしで; task:(ForgeTask *) taskNSLogは機能します。

どうすればこれを回避できますか?

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 に答える