首页 \ 问答 \ 设备就绪ios无法正常工作(Device Ready ios not working)

设备就绪ios无法正常工作(Device Ready ios not working)

我知道这种情况重复了很多次,但我找不到解决问题的方法。 我们有一个在Android上运行的应用程序没有问题。

但是当我在我的iphone中安装它时,设备就绪并没有被解雇。

设备准备跳转到android但在ios中如果auto-hide-splash-screen为false它会一直停留在splashscreen中并且deviceready不会被触发。

我正在使用phonegap构建进行构建。

cordova的版本是3.7.0

准备好的设备的代码是

 document.addEventListener('deviceready', function() {
    alert('listening to device ready'+navigator);
    navigator.splashscreen.hide();      
  }, false);        

I know this is repeated like ton of times but I cannot find the way to resolve it. We have an app running in android with no problems.

But when I install it in my iphone the device ready does not get fired.

The device ready jumps in android but in ios if auto-hide-splash-screen is false it keeps stuck in the splashscreen and deviceready is not fired.

I am making the build with phonegap build.

The version of cordova is 3.7.0

the code of the device ready is

 document.addEventListener('deviceready', function() {
    alert('listening to device ready'+navigator);
    navigator.splashscreen.hide();      
  }, false);        

原文:https://stackoverflow.com/questions/30099561
更新时间:2023-12-01 08:12

最满意答案

我过去成功使用了Boost.Multi_index。 从第一眼看你可能会觉得很奇怪,但实际上它已经退出了有趣的图书馆。 请记住,使用它时,你不会在你的定制容器中提供“如何”,而是“什么”。 假设你有以下类型:

struct user_t
{
    string id, name, email;
    int age;
    friend ostream& operator<<(ostream& output_stream, const user_t& user)
    {
        return output_stream
            << user.id    << " "
            << user.name  << " "
            << user.age   << " "
            << user.email << "\n";
    }
    friend istream& operator>>(istream& input_stream, user_t& user)
    {
        return input_stream >> user.id >> user.name >> user.age >> user.email;
    }
};

会发生什么是您创建一个容器,它包含对象和任意数量的索引。 在我们开始之前,让我们定义索引的标签。 标签只是标签! 你用来通过名称而不是神奇数字来访问你的指数:

struct by_id    { };
struct by_name  { };
struct by_age   { };
struct by_email { };

然后我们用所需的索引定义我们的“数据库”:

typedef multi_index_container<
    user_t,
    indexed_by
    <
      ordered_unique<tag<by_id>, member<user_t, string, &user_t::id> >,
      ordered_non_unique<tag<by_name>, member<user_t, string, &user_t::name> >,
      ordered_non_unique<tag<by_age>, member<user_t, int, &user_t::age> >,
      ordered_non_unique<tag<by_email>, member<user_t, string, &user_t::email> >
    >
> user_db;

首先是容器中元素的类型。 然后,你说我想通过以下索引这个容器:

indexed_by
<
  ordered_unique<tag<by_id>, member<user_t, string, &user_t::id> >,
  ordered_non_unique<tag<by_name>, member<user_t, string, &user_t::name> >,
  ordered_non_unique<tag<by_age>, member<user_t, int, &user_t::age> >,
  ordered_non_unique<tag<by_email>, member<user_t, string, &user_t::email> >
>

您只需指定要公开的索引类型即可。 实际上有各种类型,它取决于你拥有的数据的语义。 给每个索引(第一个参数)赋予一个标签是很好的,并且您指定要通过第二个模板参数的内容来索引该类型。 实际上有多种方式来选择数据的“关键”。 关键并不要求实际上是唯一的!

从现在起,你只需要像普通的std::multi_set那样处理std::multi_set ! 实际上有所不同;)让我们假设你想从文件中加载系列化用户的信息,并根据我们创建的indecies预订有序的信息:

 user_db load_information()
{
    ifstream info_file("information.txt");
    user_db db;
    user_t user;
    while(info_file >> user)
        db.insert(user);
    return db;
}
template <typename index_t>
void save_information_by(ostream& output_stream, const index_t& index)
{
    ostream_iterator<user_t> serializer(output_stream);
    copy(index.begin(), index.end(), serializer);
}
int main()
{
    ofstream
        by_id_file("by_id.txt"),
        by_name_file("by_name.txt"),
        by_age_file("by_age.txt"),
        by_email_file("by_email.txt");
    user_db db = load_information();
    // You see why we created the tags,
    // if we didn't we had to specify the index like the following:
    // const auto& name_index  = db.get<by_name>(); ==
    // const auto& name_index  = db.get<1>();
    const auto& id_index    = db.get<by_id>();
    const auto& name_index  = db.get<by_name>();
    const auto& age_index   = db.get<by_age>();
    const auto& email_index = db.get<by_email>();
    save_information_by(by_id_file, id_index);
    save_information_by(by_name_file, name_index);
    save_information_by(by_age_file, age_index);
    save_information_by(by_email_file, email_index);
}

I have used Boost.Multi_index successfully in the past. You might find it strange from a first look but in reality it is quit interesting library. Keep in mind when using it, that you don't provide "how" but "what" in your customized container. Assume that you have the following type:

struct user_t
{
    string id, name, email;
    int age;
    friend ostream& operator<<(ostream& output_stream, const user_t& user)
    {
        return output_stream
            << user.id    << " "
            << user.name  << " "
            << user.age   << " "
            << user.email << "\n";
    }
    friend istream& operator>>(istream& input_stream, user_t& user)
    {
        return input_stream >> user.id >> user.name >> user.age >> user.email;
    }
};

What will happen is that you create one container, that holds the objects and as many indices as you want. Before we start lets define the tags of indices. The tags are simply tags! that you use to access your indices by name instead of by magical numbers:

struct by_id    { };
struct by_name  { };
struct by_age   { };
struct by_email { };

Then we define our "data base" with the required indices:

typedef multi_index_container<
    user_t,
    indexed_by
    <
      ordered_unique<tag<by_id>, member<user_t, string, &user_t::id> >,
      ordered_non_unique<tag<by_name>, member<user_t, string, &user_t::name> >,
      ordered_non_unique<tag<by_age>, member<user_t, int, &user_t::age> >,
      ordered_non_unique<tag<by_email>, member<user_t, string, &user_t::email> >
    >
> user_db;

First thing is the type of elements in the container. Then, you say I want to index this container by the following:

indexed_by
<
  ordered_unique<tag<by_id>, member<user_t, string, &user_t::id> >,
  ordered_non_unique<tag<by_name>, member<user_t, string, &user_t::name> >,
  ordered_non_unique<tag<by_age>, member<user_t, int, &user_t::age> >,
  ordered_non_unique<tag<by_email>, member<user_t, string, &user_t::email> >
>

You just specify the type of index you want expose. There are various types actually, and it depends on the semantics of the data you have. It is good to give a tag for each index(the first parameter), and you specify you want to index the type by what through the second template parameter. There are various ways actually to choose the "key" of the data. The key is not required to be unique actually!

From now on, you just deal with user_db just like regular std::multi_set! with a small difference that makes the difference actually ;) Lets say you want to load serilaized users' information from a file, and reserlize ordered information according to the indecies we created:

 user_db load_information()
{
    ifstream info_file("information.txt");
    user_db db;
    user_t user;
    while(info_file >> user)
        db.insert(user);
    return db;
}
template <typename index_t>
void save_information_by(ostream& output_stream, const index_t& index)
{
    ostream_iterator<user_t> serializer(output_stream);
    copy(index.begin(), index.end(), serializer);
}
int main()
{
    ofstream
        by_id_file("by_id.txt"),
        by_name_file("by_name.txt"),
        by_age_file("by_age.txt"),
        by_email_file("by_email.txt");
    user_db db = load_information();
    // You see why we created the tags,
    // if we didn't we had to specify the index like the following:
    // const auto& name_index  = db.get<by_name>(); ==
    // const auto& name_index  = db.get<1>();
    const auto& id_index    = db.get<by_id>();
    const auto& name_index  = db.get<by_name>();
    const auto& age_index   = db.get<by_age>();
    const auto& email_index = db.get<by_email>();
    save_information_by(by_id_file, id_index);
    save_information_by(by_name_file, name_index);
    save_information_by(by_age_file, age_index);
    save_information_by(by_email_file, email_index);
}

相关问答

更多
  • 该标准比大多数人似乎认识到的更多地涉及这一点。 具体而言,该标准要求(§23.2.5/ 9): 无序关联容器的元素被组织成桶。 具有相同散列码的密钥出现在同一个存储桶中。 该接口包含一个运行时间恒定的bucket_count 。 (表103)。 它还包含一个bucket_size ,它必须在时间线上运行,并且与bucket的大小保持一致。 这基本上描述了一个使用碰撞链的实现。 当你使用碰撞链时,满足所有的要求是简单和微不足道的。 bucket_count()是数组中元素的数量。 bucket_size()是 ...
  • “STL” 是由Alexander Stepanov在C ++标准化之前的几天写的 。 C ++存在于80年代,但是我们现在称为“ C ++ ”是ISO / IEC 14882:2014(以及较早版本,如ISO / IEC 14882:2011)中标准化的语言。 STL已被广泛用作C ++的库,使程序员可以访问容器,迭代器和算法。 当标准化发生时,语言委员会设计了C ++标准库(这是语言标准的一部分)的部分,以非常接近STL。 多年来,许多人 - 包括着名书籍作家和各种网站 - 继续将C ++标准图书馆称为 ...
  • 您可以像这样使用std::find_if : std::find_if(numbers.begin(), numbers.end(), [&](std::unique_ptr& p) { return p.get() == x;}); You can use std::find_if like this: std::find_if(numbers.begin(), numbers.end(), [&](std::unique_ptr& p) { return p.get() == x;} ...
  • 我过去成功使用了Boost.Multi_index。 从第一眼看你可能会觉得很奇怪,但实际上它已经退出了有趣的图书馆。 请记住,使用它时,你不会在你的定制容器中提供“如何”,而是“什么”。 假设你有以下类型: struct user_t { string id, name, email; int age; friend ostream& operator<<(ostream& output_stream, const user_t& user) { retur ...
  • 因为C ++集合是由T的比较运算符排序的,所以可以以可预测的方式迭代成员。 如果你知道你所要做的全部工作是插入,测试成员和/或删除元素,那么自C ++ 11以来, std::unordered_set就实现了一个哈希集合。 Because C++ sets are ordered by the T's comparison operator, which makes it possible to iterate over the members in a predictable way. If you kn ...
  • 您要查找的数据结构是一个订单统计树 ,它是一个二叉搜索树,其中每个节点存储以该节点为根的子树的大小。 这支持O(log n)中列出的所有操作。 在GNU基于策略的数据结构 (GNU C ++的一部分)中存在一个顺序统计树。 代码看起来像这样: #include #include #include using namespace std; using namespac ...
  • 你可以使用元组而不是一对吗? (见答案的结尾) 如果你不能(因为你没有使用C ++ 11),要在你的对中使用find,你不需要你的比较器: typedef pair> my_type; typedef set set_of_mytype; set_of_mytype myset; myset.insert(make_pair(1,make_pair(3,4))); set_of_mytype::iterator search ...
  • 不,它不是昂贵的(渐近)。 根据C ++标准,它是在线性时间内完成的,因为每个步骤都需要恒定的时间(摊销)。 虽然通过实际排序的数组(例如std::vector或plain C数组),由于较低的常量,可能会稍快一些。 No, it is not costly (asymptotically). According to C++ standard it's done in linear time because each step takes constant time (amortized). Althou ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)