我想检查我的相机是否已连接,但我似乎无法让它工作。我添加了可达性 .h 和 .m。感谢您对我的学校项目的所有帮助!
- (void)viewDidAppear:(BOOL)animated {
Reachability *reachabilityForCam = [Reachability reachabilityWithAddress:struct sockaddr_in callAddress;
callAddress.sin_len = sizeof(callAddress);
callAddress.sin_family = AF_INET;
callAddress.sin_port = htons(80);
callAddress.sin_addr.s_addr = inet_addr("X.X.X.X")];
if ([reachabilityForCam currentReachabilityStatus] == NotReachable) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Cam is not reachable" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
[alertView show];
[self dismissModalViewControllerAnimated:YES];
}
}