我想检查用户是否在iOS 5.0以下运行应用程序,并在应用程序中显示一个标签。

我如何以编程方式检测哪个iOS正在用户的设备上运行?

谢谢!

如何在Wireshark上捕获移动电话流量?

因此,我一直在做一些研究,我一直试图拼凑一个函数,在PHP中生成一个有效的v4 UUID。这是我能做的最接近的事了。我对十六进制、十进制、二进制、PHP的位运算符之类的知识几乎一无所知。这个函数生成一个有效的v4 UUID,直到一个区域。v4 UUID的形式应该是:

xxxxx-xxxx-4xxx-yxxx-xx

y等于8,9,a或b,这就是函数失败的地方,因为它不符合这一点。

我希望在这方面比我更有知识的人能帮我一把,帮我修复这个函数,这样它就遵守了这个规则。

函数如下:

<?php

function gen_uuid() {
 $uuid = array(
  'time_low'  => 0,
  'time_mid'  => 0,
  'time_hi'  => 0,
  'clock_seq_hi' => 0,
  'clock_seq_low' => 0,
  'node'   => array()
 );
 
 $uuid['time_low'] = mt_rand(0, 0xffff) + (mt_rand(0, 0xffff) << 16);
 $uuid['time_mid'] = mt_rand(0, 0xffff);
 $uuid['time_hi'] = (4 << 12) | (mt_rand(0, 0x1000));
 $uuid['clock_seq_hi'] = (1 << 7) | (mt_rand(0, 128));
 $uuid['clock_seq_low'] = mt_rand(0, 255);
 
 for ($i = 0; $i < 6; $i++) {
  $uuid['node'][$i] = mt_rand(0, 255);
 }
 
 $uuid = sprintf('%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x',
  $uuid['time_low'],
  $uuid['time_mid'],
  $uuid['time_hi'],
  $uuid['clock_seq_hi'],
  $uuid['clock_seq_low'],
  $uuid['node'][0],
  $uuid['node'][1],
  $uuid['node'][2],
  $uuid['node'][3],
  $uuid['node'][4],
  $uuid['node'][5]
 );
 
 return $uuid;
}

?>

我刚刚升级到Xcode 4.5 GM,发现你现在可以将“4英寸视网膜”大小应用到故事板中的视图控制器上。

现在,如果我想创建一个同时在iPhone 4和5上运行的应用程序,当然我必须构建每个窗口两次,但我还必须检测用户的iPhone屏幕是3.5英寸还是4英寸,然后应用视图。

我该怎么做呢?

我一直在研究一种方法,在多个设备(如iPad或Mac)之间同步存储在iPhone应用程序中的核心数据。在iOS上,用于core data的同步框架并不多(如果有的话)。然而,我一直在思考以下概念:

A change is made to the local core data store, and the change is saved. (a) If the device is online, it tries to send the changeset to the server, including the device ID of the device which sent the changeset. (b) If the changeset does not reach the server, or if the device is not online, the app will add the change set to a queue to send when it does come online. The server, sitting in the cloud, merges the specific change sets it receives with its master database. After a change set (or a queue of change sets) is merged on the cloud server, the server pushes all of those change sets to the other devices registered with the server using some sort of polling system. (I thought to use Apple's Push services, but apparently according to the comments this is not a workable system.)

有什么特别的需要我考虑的吗?我已经研究了REST框架,如ObjectiveResource、Core Resource和RestfulCoreData。当然,这些都是与Ruby on Rails一起工作的,我并不依赖于Ruby on Rails,但这是一个起点。我的解决方案的主要要求是:

任何更改都应该在后台发送,而不需要暂停主线程。 它应该使用尽可能少的带宽。

我想过一些挑战:

Making sure that the object IDs for the different data stores on different devices are attached on the server. That is to say, I will have a table of object IDs and device IDs, which are tied via a reference to the object stored in the database. I will have a record (DatabaseId [unique to this table], ObjectId [unique to the item in the whole database], Datafield1, Datafield2), the ObjectId field will reference another table, AllObjects: (ObjectId, DeviceId, DeviceObjectId). Then, when the device pushes up a change set, it will pass along the device Id and the objectId from the core data object in the local data store. Then my cloud server will check against the objectId and device Id in the AllObjects table, and find the record to change in the initial table. All changes should be timestamped, so that they can be merged. The device will have to poll the server, without using up too much battery. The local devices will also need to update anything held in memory if/when changes are received from the server.

我还遗漏了什么吗?我应该考虑什么样的框架来实现这一点?

我如何让一个JavaScript动作对当前页面有一些影响,但也会改变浏览器中的URL,这样当用户点击重新加载或书签时,就会使用新的URL ?

如果后退按钮可以重新加载原始URL,那就太好了。

我试图在URL中记录JavaScript状态。

我试图使用UIImagePickerController与UIImagePickerControllerSourceTypePhotoLibrary,但它说,“没有照片”。模拟器从哪里获得图像?我应该在哪里复制图像,以便它们在模拟器中显示?

所以,标题应该不言自明。

在ASP中创建可重用的组件。NET MVC,我们有3个选项(可能是其他我没有提到的):

局部视图:

@Html.Partial(Model.Foo, "SomePartial")

定制编辑器模板:

@Html.EditorFor(model => model.Foo)

自定义显示模板:

@Html.DisplayFor(model => model.Foo)

就实际的View/HTML而言,所有三种实现都是相同的:

@model WebApplications.Models.FooObject

<!-- Bunch of HTML -->

所以,我的问题是——何时/如何决定使用三种方法中的哪一种?

我真正想要的是在创建一个之前问自己的问题列表,答案可以用来决定使用哪个模板。

以下是我发现EditorFor/DisplayFor更好的2件事:

They respect model hierarchies when rendering HTML helpers (e.g if you have a "Bar" object on your "Foo" model, the HTML elements for "Bar" will be rendered with "Foo.Bar.ElementName", whilst a partial will have "ElementName"). More robust, e.g if you had a List<T> of something in your ViewModel, you could use @Html.DisplayFor(model => model.CollectionOfFoo), and MVC is smart enough to see it's a collection and render out the single display for each item (as opposed to a Partial, which would require an explicit for loop).

我也听说过DisplayFor呈现一个“只读”模板,但我不明白-我不能扔一个表单在那里吗?

有人能告诉我其他原因吗?有没有比较这三个的列表/文章?

我已经开始使用webpack2(准确地说,v2.3.2),在重新创建我的配置后,我一直遇到一个问题,我似乎无法解决我得到(提前为丑陋的转储道歉):

ERROR in ./src/main.js
Module not found: Error: Can't resolve 'components/DoISuportIt' in '[absolute path to my repo]/src'
resolve 'components/DoISuportIt' in '[absolute path to my repo]/src'
  Parsed request is a module
  using description file: [absolute path to my repo]/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    aliased with mapping 'components': '[absolute path to my repo]/src/components' to '[absolute path to my repo]/src/components/DoISuportIt'
      using description file: [absolute path to my repo]/package.json (relative path: ./src)
        Field 'browser' doesn't contain a valid alias configuration
      after using description file: [absolute path to my repo]/package.json (relative path: ./src)
        using description file: [absolute path to my repo]/package.json (relative path: ./src/components/DoISuportIt)
          as directory
            [absolute path to my repo]/src/components/DoISuportIt doesn't exist
          no extension
            Field 'browser' doesn't contain a valid alias configuration
            [absolute path to my repo]/src/components/DoISuportIt doesn't exist
          .js
            Field 'browser' doesn't contain a valid alias configuration
            [absolute path to my repo]/src/components/DoISuportIt.js doesn't exist
          .jsx
            Field 'browser' doesn't contain a valid alias configuration
            [absolute path to my repo]/src/components/DoISuportIt.jsx doesn't exist
[[absolute path to my repo]/src/components/DoISuportIt]
[[absolute path to my repo]/src/components/DoISuportIt]
[[absolute path to my repo]/src/components/DoISuportIt.js]
[[absolute path to my repo]/src/components/DoISuportIt.jsx]

package.json

{
  "version": "1.0.0",
  "main": "./src/main.js",
  "scripts": {
    "build": "webpack --progress --display-error-details"
  },
  "devDependencies": {
    ...
  },
  "dependencies": {
    ...
  }
}

关于它所抱怨的浏览器字段,我能够找到的文档是:package-browser-field-spec。也有webpack文档,但它似乎默认开启:aliasFields: ["browser"]。我尝试在我的包中添加一个浏览器字段。Json,但这似乎没有任何好处。

webpack.config.js

import path from 'path';
const source = path.resolve(__dirname, 'src');

export default {
  context: __dirname,
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js',
  },
  resolve: {
    alias: {
      components: path.resolve(__dirname, 'src/components'),
    },
    extensions: ['.js', '.jsx'],
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        include: source,
        use: {
          loader: 'babel-loader',
          query: {
            cacheDirectory: true,
          },
        },
      },
      {
        test: /\.css$/,
        include: source,
        use: [
          { loader: 'style-loader' },
          {
            loader: 'css-loader',
            query: {
              importLoader: 1,
              localIdentName: '[path]___[name]__[local]___[hash:base64:5]',
              modules: true,
            },
          },
        ],
      },
    ],
  },
};

src / main.js

import DoISuportIt from 'components/DoISuportIt';

src /组件/ DoISuportIt / index.jsx

export default function() { ... }

为完整起见,.babelrc

{
  "presets": [
    "latest",
    "react"
  ],
  "plugins": [
    "react-css-modules"
  ],
  "env": {
    "production": {
      "compact": true,
      "comments": false,
      "minified": true
    }
  },
  "sourceMaps": true
}

我做错了什么/遗漏了什么?

我是一名网络开发人员,我想把我的网络产品搬到iPhone上。其中一个产品就像谷歌Maps:在手机屏幕上显示地图,您可以拖动或调整地图的大小,并查看我们添加到地图的一些信息。

我知道有一些技术可以让你使用HTML、CSS和Javascript来开发原生iPhone应用。我列举了一些:

Ansca移动 PhoneGap Appcelerator

还有其他类似的产品吗?它们之间有什么区别?我该选哪一个呢?