Codeigniter user_agent无法正常工作

I have used the following to detect mobile, robot and desktop as described in user documentation of codeigniter.

     if ($this->agent->is_mobile()) {
           // This is a mobile device
        $data['is_mobile'] = true;
        $this->load->view('mobile/template/header');
        $this->load->view('mobile/template/imageDiv', $data);
        $this->load->view('mobile/template/footer');       
        } else if ($this->agent->is_robot()) {
            // This is a robot, treat it like a mobile device so that our content is indexed
        $data['is_mobile'] = true;
        $this->load->view('mobile/template/header');
        $this->load->view('mobile/template/imageDiv', $data);
        $this->load->view('mobile/template/footer');       

        } else {
        $data['is_mobile'] = false;
        $this->load->view('template/header');

        $this->load->view('login/loginOnHover', $data);
        $this->load->view('template/imageDiv', $data);
        $this->load->view('template/booking_track', $data);
        $this->load->view('template/recent_hotels', $data);
        $this->load->view('template/easybooking');
        $this->load->view('template/features');
        $this->load->view('template/stepsApi', $data);
        $this->load->view('template/footer');       
    }

It is working fine for almost all mobile devices, but for google nexus series, blackberry PlayBook and Ipads it shows the desktop view. How could I solve it?

Try this way:-

In application/libraries/MY_User_agent.php:

class MY_User_agent extends CI_User_agent {

    public function __construct()
    {
        parent::__construct();
    }

    public function is_ipad()
    {
        return (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
          // You can add other checks for other tablets
    }
}

Check by this way:-

    $this->load->library('user_agent');

    ($this->agent->is_ipad() === TRUE) ? $is_ipad = "Yes" : $is_ipad = "No";

    echo "Using ipad: $is_ipad";