-(IBAction)camMoveUp
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.2/decoder_control.cgicommand=0&user=myusername&pwd=mypassword"]];
// Perform request and get JSON as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSLog(@"response=%@",response );
}
或者,您可以在您的视图中使用 webView 并打开 URL
-(IBAction)camMoveUp
{
//Create Webview Programatically
CGRect webFrame = CGRectMake(0.0,100.0, 320.0,360.0);
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor Whitecolor]];
[self.view addsubview:webview];
//Load The URL to Open
NSString *urlAddress = @"http://192.168.1.2/decoder_control.cgicommand=0&user=myusername&pwd=mypassword";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
webview.delegate=self;
[webView loadRequest:requestObj];
}
如果你想在页面加载后做一些活动,那么你可以使用 webview 委托函数。检查这里是 WebView 的完整教程。