设备就绪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
最满意答案
我过去成功使用了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); }
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
该标准比大多数人似乎认识到的更多地涉及这一点。 具体而言,该标准要求(§23.2.5/ 9): 无序关联容器的元素被组织成桶。 具有相同散列码的密钥出现在同一个存储桶中。 该接口包含一个运行时间恒定的bucket_count 。 (表103)。 它还包含一个bucket_size ,它必须在时间线上运行,并且与bucket的大小保持一致。 这基本上描述了一个使用碰撞链的实现。 当你使用碰撞链时,满足所有的要求是简单和微不足道的。 bucket_count()是数组中元素的数量。 bucket_size()是 ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
“STL” 是由Alexander Stepanov在C ++标准化之前的几天写的 。 C ++存在于80年代,但是我们现在称为“ C ++ ”是ISO / IEC 14882:2014(以及较早版本,如ISO / IEC 14882:2011)中标准化的语言。 STL已被广泛用作C ++的库,使程序员可以访问容器,迭代器和算法。 当标准化发生时,语言委员会设计了C ++标准库(这是语言标准的一部分)的部分,以非常接近STL。 多年来,许多人 - 包括着名书籍作家和各种网站 - 继续将C ++标准图书馆称为 ...
-
搜索一组独特的指针(Searching a set of unique pointers)[2021-08-20]
您可以像这样使用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;} ... -
在不同的标准C ++ STL上维护一组独特的元素(Maintaining a unique set of elements on different criteria C++ STL)[2022-07-22]
我过去成功使用了Boost.Multi_index。 从第一眼看你可能会觉得很奇怪,但实际上它已经退出了有趣的图书馆。 请记住,使用它时,你不会在你的定制容器中提供“如何”,而是“什么”。 假设你有以下类型: struct user_t { string id, name, email; int age; friend ostream& operator<<(ostream& output_stream, const user_t& user) { retur ... -
C ++ STL集合实现(C++ STL set implementation)[2024-03-08]
因为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 ... -
适用于查找动态有序列表中第n个元素的C ++ STL容器?(C++ STL container suited for finding the nth element in dynamic ordered list?)[2022-08-14]
您要查找的数据结构是一个订单统计树 ,它是一个二叉搜索树,其中每个节点存储以该节点为根的子树的大小。 这支持O(log n)中列出的所有操作。 在GNU基于策略的数据结构 (GNU C ++的一部分)中存在一个顺序统计树。 代码看起来像这样: #include#include #include using namespace std; using namespac ... -
find()在C ++ stl中的用法(find() usage in C++ stl)[2022-04-03]
你可以使用元组而不是一对吗? (见答案的结尾) 如果你不能(因为你没有使用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 ...