标签: universal

iPhone在通用应用程序中检查运行时的常量

我正在制作一个通用的iPad/iPhone应用程序,可以使用iPad的VGA输出连接器在外部屏幕上镜像应用程序的内容.但是,iPhone没有此功能.给出以下代码,

#ifdef UI_USER_INTERFACE_IDIOM  
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    NSLog(@"this code should not execute on iphone");
[[NSNotificationCenter defaultCenter] addObserver:self
         selector:@selector(screenInfoNotificationReceieved:) 
          name:UIScreenDidConnectNotification
           object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
         selector:@selector(screenInfoNotificationReceieved:) 
          name:UIScreenDidDisconnectNotification
           object:nil];
}
#endif
Run Code Online (Sandbox Code Playgroud)

我在启动时在手机上收到此错误(在ipad中正常工作)"dyld:找不到符号:_UIScreenDidConnectNotification"

大概是因为UIScreenDidConnectNotification在3.13中还没有存在.如何在运行时检查?

UPDATED 添加了ifdef语句来检查ipad接口,但获得了相同的结果!

UPDATED添加了NSLog语句,以确保不调用if语句中的代码.崩溃似乎发生在任何其他代码执行之前...

iphone universal ipad

5
推荐指数
1
解决办法
3249
查看次数

试图让我的应用程序通用

www使用PhoneGap框架在我的文件夹上有两个HTML文件.iPhone/iPod one(/mobile/index.html)和iPad one(/index.html).所以我在我的代码中使用此代码AppDelegate.m:

+ (NSString*) startPage
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return @"index.html";
    } else {
        return @"mobile/index.html";
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑我Targeted Device FamilyiPhone/iPad.

但由于某种原因它不起作用.当我把它放在我的iPad上时,它仍然将应用程序置于兼容模式.我该怎么办?

iphone universal ipad ios cordova

5
推荐指数
1
解决办法
604
查看次数

将简单的iPhone应用转换为通用应用

我有很简单的iPhone应用程序,它仅使用UIButtons,UIlabels,UITableView.没有任何自定义控制器和图形.如何使用该UI将应用程序转换为通用?

iphone xcode universal ipad ios

5
推荐指数
1
解决办法
1万
查看次数

在iOS中编写通用应用程序

当我编写通用应用程序时,假设我有这样的IBAction:

(IBAction)magicCode:(id)sender {

    textField1.text = "TEST";

}
Run Code Online (Sandbox Code Playgroud)

我是否需要为每个视图(iPad和iPhone)创建新的IBAction.我不能在头文件中使用textField1两次,所以我只是想知道其他人是如何做到这一点的.我是否需要在iPhone应用程序中放置一个文本字段,其名称与iPad应用程序中的名称不同?或者其他人是否有其他方式这样做?

objective-c universal ibaction ios

5
推荐指数
1
解决办法
540
查看次数

在Windows Universal App中使用StatusBar

我正在尝试使用以下代码从视图构造函数中检索StatusBar对象: bool mobile = Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract",1,0); if(mobile) { var statusbar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); }

使用Visual Studio Community 2015,我收到以下错误: Error CS0731 The type forwarder for type 'Windows.UI.ViewManagement.StatusBar' in assembly 'Windows' causes a cycle Error CS1069 The type name 'StatusBar' could not be found in the namespace 'Windows.UI.ViewManagement'. This type has been forwarded to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' Consider adding a reference to that assembly.

根据微软的说法,这个类应该存在.我甚至为Mobile设备系列添加了对Package.appxmanifest的依赖,但仍然没有.有任何想法吗?

.net c# windows universal

5
推荐指数
1
解决办法
2511
查看次数

Webpack 2代码分割与服务器端渲染和React-Router-v4

使用webpack2.2.0-rc1并对routerv4做出反应,并使用此要点使代码拆分工作,其中说明以下内容

function asyncComponent(getComponent) {
  return class AsyncComponent extends React.Component {
    static Component = null;
    state = { Component: AsyncComponent.Component };

    componentWillMount() {
      if (!this.state.Component) {
        getComponent().then(Component => {
          AsyncComponent.Component = Component
          this.setState({ Component })
        })
      }
    }
    render() {
      const { Component } = this.state
      if (Component) {
        return <Component {...this.props} />
      }
      return null
    }
  }
}

const Foo = asyncComponent(() =>
  System.import('./Foo').then(module => module.default)
)
Run Code Online (Sandbox Code Playgroud)

它确实有效,但我正在使用服务器端渲染.所以在服务器上我需要组件A,然后在客户端I System.import组件A.当我访问延迟加载的路由时,我得到这个反应重用标记警告,因为客户端呈现最初从https://gist.github加载null .com/acdlite/a68433004f9d6b4cbc83b5cc3990c194#file-app-js-L21 加载组件A. Warning: React attempted to reuse …

javascript node.js universal reactjs code-splitting

5
推荐指数
1
解决办法
1402
查看次数

Angular 2:可以将应用程序外壳与通用渲染结合起来

我有一个标准的 angular-cli 生成的项目。为其创建应用程序外壳并将其与 ng-universal 的服务器渲染技术相结合是否有意义?

如果是这样,那么最好的方法是什么?

universal angular app-shell

5
推荐指数
1
解决办法
1410
查看次数

Angular 4 Universal“窗口未定义”

我的项目运行完美,但是当我实现通用时,我得到“窗口未定义”。

我的错误如下。

 node_modules/hammerjs/hammer.js:2643

 })(window, document, 'Hammer');

      ^
  ReferenceError: window is not defined
     at Object.<anonymous> (/var/www/html/resumeble_unv/node_modules/hammerjs  /hammer.js:2643:4) 

      at Module._compile (module.js:571:32)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:488:32)
      at tryModuleLoad (module.js:447:12)
     at Function.Module._load (module.js:439:3)
     at Module.require (module.js:498:17)
     at require (internal/module.js:20:19)
     at node_modules/ngx-carousel/bundles /ngxcarousel.umd.js:2:174
    at Object.<anonymous> (node_modules/ngx-carousel/bundles/ngxcarousel.umd.js:5:2)
Run Code Online (Sandbox Code Playgroud)

包.json

  { 
  "name": "resumable-ang",

  "version": "0.0.0",

  "license": "MIT",

  "scripts": {
   "prestart": "ng build --prod && ngc",
    "start": "ts-node src/server.ts" },

   "private": true,
  "dependencies": {

  "@angular/animations": "^4.4.6",
  "@angular/common": "^4.0.0",
  "@angular/compiler": "^4.0.0",
  "@angular/core": "^4.0.0",
 "@angular/forms": "^4.0.0",
  "@angular/http": "^4.0.0",
  "@angular/platform-browser": …
Run Code Online (Sandbox Code Playgroud)

universal angular

5
推荐指数
1
解决办法
3916
查看次数

预启动非工作客户端应用程序 - Angular 6 通用

angular 6应用程序上使用预启动时遇到问题。

基本上,客户端应用程序根本不起作用,特定于客户端的脚本不起作用(例如滚动侦听器、HTTP 调用等,我认为实际上没有控制器),样式消失了(与以下问题相同:组件 CSS)在 App Bootsrapping with Preboot 期间从组件中消失

服务器应用程序工作正常(它仍然存在于 DOM 中,但带有显示:无,请参阅图像链接) DOM 捕获

有没有人有同样的问题?我没有收到任何错误(在浏览器控制台或服务器控制台上),所以我根本不知道发生了什么。

PS:我用这个答案解决了样式问题:https : //github.com/angular/preboot/issues/75#issuecomment-421266570

universal angular

5
推荐指数
0
解决办法
685
查看次数

Angular Universal无法在路由器出口内呈现内容

我正在尝试通过此链接https://angular.io/guide/universal使用Angular Universal使用SSR渲染Angular 7应用程序。我以为我可以从那里开始一切工作,因为我能够查看页面源代码并看到呈现给页面的app.component内部的所有内容。但是,我无法在router-outlet标记内渲染任何路线

我只是简单地剥离了我的应用程序,以完全按照文档中的说明进行操作。我在其中读到了一些有关确保ModuleMapLoaderModule在app.server.module内部的内容,以便进行延迟加载。默认情况下,angular-cli命令会附带此命令,因此我不确定发生了什么。

app.server.module

import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';

import { AppComponent } from './app.component';
import { AppModule } from './app.module';

@NgModule({
  imports: [
    AppModule,
    ServerModule,
    ModuleMapLoaderModule,
  ],
  bootstrap: [AppComponent],
})
export class AppServerModule {}
Run Code Online (Sandbox Code Playgroud)

tsconfig.server.json

  "extends": "./tsconfig.app.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app-server",
  },
  "angularCompilerOptions": {
    "entryModule": "app/app.server.module#AppServerModule"
  }
}
Run Code Online (Sandbox Code Playgroud)

server.ts

import 'zone.js/dist/zone-node';
import { enableProdMode } from '@angular/core';
// Express …
Run Code Online (Sandbox Code Playgroud)

universal angular-universal ssr angular angular7

5
推荐指数
1
解决办法
789
查看次数