1

我正在我的应用程序中测试登录。这是页面的源代码:

    <label for="login">Username:</label><br/>
    <input id="login"  name="login"/><br/>              
    <label for="password">Password:</label><br/>
    <input id="password" name="password" type="password"/><br/>
    <input type="SUBMIT" class="tasto" value="Conferma" name="evn_conferma=evento"/>

我试过这个:

ASIFormDataRequest * request2 = [ASIFormDataRequest requestWithURL:url];
[request2 setPostValue:@"USERNAME" forKey:@"login"];
[request2 setPostValue:@"PASSWORD" forKey:@"password"];


#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
   [request2 setShouldContinueWhenAppEntersBackground:YES];
#endif

[request2 setDelegate:self];
[request2 setDidFailSelector:@selector(uploadFailed:)];
[request2 setDidFinishSelector:@selector(uploadFinished:)];
[request2 startSynchronous];

但是什么都没有加载。请帮帮我!

编辑:我想我需要一些关于Conferma 按钮的信息。

- (void)uploadFinished:(ASIHTTPRequest *)theRequest
{

NSString *responseString = [theRequest responseString]; 
NSLog(@"%@",responseString); 
NSLog(@"Finished uploading %llu bytes of data",[theRequest postLength]);

}

关于最后一种方法,如果我把字符串

[request2 setPostValue:@"Conferma" forKey:@"evn_conferma=evento"];

我看到上传0字节!!!

4

1 回答 1

0

我猜这不是一个修复,但你应该改变

[request2 startSynchronous];

[request2 startAsynchronous];

由于您将委托与自我挂钩,因此您应该使其异步

还添加以下内容

[request2 setPostValue:@"Conferma" forKey:@"evn_conferma=evento"];
于 2012-06-01T21:43:42.667 回答