如何用php检测iOS版本?

时间:2015-11-02 04:27:28

标签: php ios iphone

如何使用php检测iOS版本。我正在尝试使用解决方案$_SERVER['HTTP_USER_AGENT'],但它会显示:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 8_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7

我只想显示OS 8_0

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

正如您所提到的,您已使用- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UserDetails *userDetails = [arrUserDetails objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"CustomCell"; __weak TableViewCell *cell = (TableViewCell *)[_tableViewUsername dequeueReusableCellWithIdentifier:CellIdentifier]; cell.tag = indexPath.row; cell.userName.text = userDetails.userName; //Add Default placeholder cell.customImageView.image = [UIImage imageNamed:@"Default.png"]; [self.operationQueue addOperationWithBlock: ^ { NSURL *aURL = [NSURL URLWithString:userDetails.userImageURL]; NSError *error = nil; NSData *data = [NSData dataWithContentsOfURL:aURL options:nil error:&error]; UIImage *image = nil; if (cell.tag == indexPath.row) { image = [UIImage imageWithData:data]; [[NSOperationQueue mainQueue] addOperationWithBlock: ^ { cell.customImageView.image = image; cell.customImageView.contentMode = UIViewContentModeScaleToFill; cell.accessoryType = UITableViewCellAccessoryCheckmark; }]; } }];

所以输出是

  

Mozilla / 5.0(iPhone; U; CPU iPhone OS 8_0 ,如Mac OS X; zh-CN)AppleWebKit / 532.9(KHTML,与Gecko一样)Version / 4.0.5 Mobile / 8A293 Safari / 6531.22.7

在上面的输出中包含了它的版本(参见上面的粗体文字)

$_SERVER['HTTP_USER_AGENT']

阅读 - Detecting iOS Version Number from User Agent using Regular Expressions