开发者

iPhone: How to send httprequest via button?

The开发者_JAVA技巧re is 1 button on a view screen, when the user clicks the button a httprequest is sent to http://domain.com/buttoninput.php?id=1

Thats it! Nothing is loaded on the screen! the page is only loaded in the background.


Try this // URL string encoding

NSString *escapedUrl = [aURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

// create the request

 NSURLRequest *aRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:escapedUrl]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; 

// create the connection with the request // and start loading the data

NSURLConnection *aConnection=[[NSURLConnection alloc] initWithRequest:aRequest delegate:self]; 


You probably (at least you should) load the data asynchronously. Upon finishing (your delegate methods are your best friends) evaluate the data your received and change your UI elements. Why would you expect anything to update automatically?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜