小编dan*_*anu的帖子

AudioHardware.cpp:1200:AudioObjectRemovePropertyListener:AudioObjectRemovePropertyListener:没有给定ID为0的对象

在swift中处理一个项目,我正在尝试启动AVPlayer,由于某种原因,我告诉我一个例外说法

AudioHardware.cpp:1200:AudioObjectRemovePropertyListener:AudioObjectRemovePropertyListener:没有给定ID为0的对象.

我想问题出在我的网址上.这是我的代码

func initPlayer() {
    let url:NSURL = NSURL(string:"https://purelight1-163000.appspot.com/api/user/v2/media/track/60/sample")!
    self.playerItem = AVPlayerItem(url: url as URL)
    self.player=AVPlayer(playerItem: self.playerItem!)
    let playerLayer=AVPlayerLayer(player: self.player!)
    playerLayer.frame = CGRect(x: 0, y: 0, width: 10, height: 50) // actually this player layer is not visible
    self.view.layer.addSublayer(playerLayer)
}
Run Code Online (Sandbox Code Playgroud)

ios avplayer swift swift4

15
推荐指数
2
解决办法
5765
查看次数

iOS 11.0中不推荐使用SLServiceTypeFacebook'

我正在使用xcode 9和以前的代码之一进行项目开发,并给出警告说该代码已被弃用,并且不会触发该操作。该代码如下。我该如何克服呢?

@IBAction func shareOnFacebookButtonPressed(_ sender: Any) {

    let shareToFacebook : SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    shareToFacebook.add(UIImage(named:"pureLightSocial"))
    self.present(shareToFacebook, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

xcode ios swift swift4 ios11

6
推荐指数
1
解决办法
6384
查看次数

类型 'List<dynamic>' 不是类型 'List<DropdownMenuItem<String>>' 的子类型

我正在处理一个颤振项目,我将一组对象(列表> 数组)从我的集团传递给流构建器。如果我打印它打印得很好的对象,但是当我尝试在 DropdownMenuItem 中映射它们时,它会抛出我提到的错误。因此,如果我在类中创建一个相同格式的虚拟数组并访问它,我不会收到错误消息。不知道我在这里错过了什么,代码如下。

          StreamBuilder(
          stream: _bLoc.getJsonArray,
          builder: (context, snapshot) {
            return snapshot.hasData
                ? new Container(
                    width: 150,
                    color: Theme.of(context).primaryColor,
                    child: new DropdownButton<String>(
                      items: snapshot.data.map((value) =>
                         new DropdownMenuItem<String>(
                          value: value["distance"],
                          child: new Text(value["distance"]),
                        )
                      ).toList(),
                      onChanged: (_) {},
                    ),
                  )
                : Container();
          }),
Run Code Online (Sandbox Code Playgroud)

我的json结构如下。

 [
  {"distance": "12km","price": "200LKR",},
  {"distance": "2km","price": "100LKR",},
  {"distance": "132km","price": "340LKR",}
 ]
Run Code Online (Sandbox Code Playgroud)

dart flutter dropdownbutton

6
推荐指数
1
解决办法
8767
查看次数

NSCache第一次加载时不适用于所有图像

我正在使用swift 3.0中的一个项目,我通过使用NSCache来缓存来自服务器的响应,以便在UITableView中填充它们.然而由于某种原因,我只看到第一次加载应用程序时加载的图片很少,但如果我滚动并返回我看到的一切(从服务器检索响应的结束我也重新加载我的tableview,但似乎不是这样).我不确定我在这里错过了什么,代码如下所示,以显示我如何缓存图像.

let imageCache = NSCache<AnyObject, AnyObject>()
var imageURLString : String?

extension UIImageView {


    public func imageFromServerURL(urlString: String) {
        imageURLString = urlString

        if let url = URL(string: urlString) {

            image = nil


            if let imageFromCache = imageCache.object(forKey: urlString as AnyObject) as? UIImage {

                self.image = imageFromCache

                return
            }

            URLSession.shared.dataTask(with: url, completionHandler: { (data, response, error) in

                if error != nil{
                    print(error as Any)


                    return
                }

                DispatchQueue.main.async(execute: {

                    if let imgaeToCache = UIImage(data: data!){

                        if imageURLString == urlString {
                            self.image = …
Run Code Online (Sandbox Code Playgroud)

ios nscache swift swift3

5
推荐指数
2
解决办法
1490
查看次数

如何更改由证书颁发机构请求证书创建的证书的有效期以上传到开发者帐户

我正在尝试从具有更高到期日期的开发人员帐户创建 p12 证书。目前我所有的 p12 都只有 1 年的有效期。我相信它可以从证书助手更改。但不确定步骤。任何见解将不胜感激。

certificate keychain apple-developer

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

将本地图像路径作为两个功能组件之间的prop

我正在研究一个反应原生的项目,在那里我很难理解道具在功能组件之间是如何工作的.我的要求是创建一个可重复使用的按钮组件,我可以在项目中的资源文件中传递图像位置,因此它将为我创建按钮.出于某种原因,如果我手动提供所需的位置,它将工作并为我创建按钮,但如果我\我通过位置作为道具从我创建它不会工作由于某种原因.我的代码如下.

按钮组件

import React, { Component } from 'react';
import {
    View,
    StyleSheet,
    Image,
    TouchableOpacity
} from 'react-native';

const ButtonWithImage = (props) => {
    const {buttonStyle} = styles;
    const clickEvent = () => {}

    return (
        <TouchableOpacity onPress= {clickEvent}style={buttonStyle}>
            <Image 
                source={props.imagePath} 
                style={styles.ImageIconStyle} 
            />
        </TouchableOpacity>
    );
};

const styles = {
    buttonStyle: {
        //alignSelf:'stretch',
        height: 50,
        width:50,
        paddingTop:0,
        flexDirection: 'row'
    }
};

export default ButtonWithImage;
Run Code Online (Sandbox Code Playgroud)

我创建按钮并通过道具的地方

import React, { Component } from 'react';
import {
    View,
    StyleSheet,
    Dimensions,
} from 'react-native'; …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-props

4
推荐指数
1
解决办法
3528
查看次数

如何在flutter中将泛型类型作为参数传递给Future

我的目标是创建一个处理 Web 服务器请求的单例类,并传递一个通用类型(这是我的数据模型)作为参数来解码并分配给我的数据模型。我部分完成的代码如下,帮助将不胜感激。

class Network{
  Future<someDataModel> _getRequest(T) async {
   print("entered");
   final response = await client
    .get("http://api.themoviedb.org/3/movie/popular?api_key=$_apiKey");
      print(response.body.toString());
   if (response.statusCode == 200) {
        // If the call to the server was successful, parse the JSON
   return T.fromJson(json.decode(response.body));
   } else {
      // If that call was not successful, throw an error.
   throw Exception('Failed to load post');
  }
 }
Run Code Online (Sandbox Code Playgroud)

在同一个类中,我使用如下公共方法访问 getRequest。因此,通过这种方法,我的目的是将我的数据模型作为泛型类型参数传递给 get 请求,并让解码部分发生。部分完成的代码如下。

 getAllList(){
  return _getRequest(dataModel);
 }
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
1
解决办法
7789
查看次数

如何使用电容器处理移动应用程序的实时更新?

我有一个react-js 应用程序,我使用电容器来利用本机移动API(例如:BLE)。我的目标是在发生微小更改(例如:添加新标签)时实时更新应用程序,而无需完成整个应用程序商店提交过程。我知道 Ionic 的 AppFlow 可以与 Capacitor 很好地配合,但它对我来说太贵了。因此,我看到一些人建议编写一个脚本,从 S3 存储桶等位置完美地引入 JS,当您构建应用程序时,您将构建所有本机代码,并将 HTML 脚本替换为来自远程源的脚本(但我不知道该怎么做)

  1. 这是大多数人处理实时更新 webview 应用程序的方式还是有更好的方法?
  2. 如果是这样,使用脚本等(带有代码示例)来实现此目标的步骤是什么?

javascript webview cordova reactjs capacitor

2
推荐指数
1
解决办法
3227
查看次数

AvPlayer无法在设备中播放声音

我的代码在模拟器中可以正常运行,并且可以毫无问题地传输URL。但是,当插入实际设备时,它不会播放音频。我的代码如下

var playerItem: AVPlayerItem?
var player: AVPlayer?

func initPlayer() {
    let url:URL = URL(string:"https://storage.googleapis.com/purelightdatabucket/samples%2F60-Energy%20UPLIFT.mp3")!
    self.playerItem = AVPlayerItem(url: url)
    self.player=AVPlayer(playerItem: self.playerItem!)
    let playerLayer=AVPlayerLayer(player: self.player!)
    playerLayer.frame = CGRect(x: 0, y: 0, width: 10, height: 50) // actually this player layer is not visible
    self.view.layer.addSublayer(playerLayer)
}
Run Code Online (Sandbox Code Playgroud)

ios avplayer swift swift3 swift4

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

Double值无法转换为Int64,因为它是无限或NaN

我是swift的新手,我正在使用swift 3.0中的一个项目,我有一个UISlider可以拖动.一旦我拖动它,我得到以下崩溃说"双值不能转换为Int64因为它是无限或NaN".我的代码如下.我该如何克服这个错误?崩溃的线是"让seekTime = CMTime(值:Int64(val),时间刻度:1)"......

@IBAction func sliderValueChanged(_ sender: UISlider) {

    if let duration = player?.currentItem?.duration {

        let totalsecs = CMTimeGetSeconds(duration)
        print("Durtion :",totalsecs)
        let val = Float64(sender.value) * totalsecs

        let totalduration = CMTimeGetSeconds(duration) as Float64

        if(val != totalduration){

            let seekTime = CMTime(value: Int64(val), timescale: 1)
            player?.seek(to: seekTime, completionHandler: { (completedSeek) in

            })
        }else{
            print("Slider dragged error")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

ios swift

0
推荐指数
1
解决办法
1044
查看次数