小编lws*_*803的帖子

如何在解散时从模态视图控制器传回数据

我按照这里的说明操作,但我仍然不确定这一部分:

modalVC.delegate=self;
        self.presentViewController(modalVC, animated: true, completion: nil) 
Run Code Online (Sandbox Code Playgroud)

我已尝试以编程方式实例化视图控制器,但仍无济于事.

这是解雇模态视图控制器时的代码:

@IBAction func dismissViewController(_ sender: UIBarButtonItem) {
        self.dismiss(animated: true) { 
            //
        }
    }
Run Code Online (Sandbox Code Playgroud)

我正在使用故事板来模拟视图.

这是我希望传输回父视图控制器的数据:

var typeState = "top"
 var categoryState = "casual"
Run Code Online (Sandbox Code Playgroud)

这是两个String值.

编辑:

我试图从模态视图控制器传递数据,如下所示:

@IBAction func dismissViewController(_ sender: UIBarButtonItem) {
        self.dismiss(animated: true, completion: nil)
        delegate?.sendValue(value: "success")
        if let presenter = presentingViewController as? OOTDListViewController {
            presenter.receivedValue = "test"
        }
    }
Run Code Online (Sandbox Code Playgroud)

而在父视图控制器上,我这样做:

func sendValue(value: NSString) {
        receivedValue = value as String
    }
  @IBAction func printReceivedValue(_ sender: UIButton) { …
Run Code Online (Sandbox Code Playgroud)

ios swift

19
推荐指数
2
解决办法
2万
查看次数

Xcode for MacOS Mojave中的C ++项目需要NSCameraUsageDescription

我试图在Xcode中运行OpenCV项目,似乎有新的需要为C ++应用程序NSCameraUsageDescription提供info.plist。

2018-09-28 00:03:15.181948+0800 k_nearest_detector_v2[23505:710470] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
Program ended with exit code: 9
Run Code Online (Sandbox Code Playgroud)

我该如何为C ++项目创建.plist文件,因为以前从未需要过它。

c++ xcode macos-mojave

6
推荐指数
2
解决办法
1953
查看次数

为 SKLabelNode 中的单个角色设置动画

有没有一种更有效的方法来在一个 sklabelnode 中通过打字来为颤抖的文本制作动画?我正在尝试在一些游戏中实现这种效果,比如传说中的文字,当它们同时颤抖时,它们会出现打字机的风格。

到目前为止,我只能实现它,但幸运的是:

class TextEffectScene: SKScene {

    var typeWriterLabel : SKLabelNode?
    var shiveringText_L : SKLabelNode?
    var shiveringText_O : SKLabelNode?
    var shiveringText_S : SKLabelNode?
    var shiveringText_E : SKLabelNode?
    var shiveringText_R : SKLabelNode?

    var button : SKSpriteNode?


    override func sceneDidLoad() {
        button = self.childNode(withName: "//button") as? SKSpriteNode

        self.scaleMode = .aspectFill //Very important for ensuring that the screen sizes do not change after transitioning to other scenes

        typeWriterLabel = self.childNode(withName: "//typeWriterLabel") as? SKLabelNode
        shiveringText_L = self.childNode(withName: "//L") as? SKLabelNode
        shiveringText_O = self.childNode(withName: …
Run Code Online (Sandbox Code Playgroud)

sprite-kit skspritenode swift3

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

颤动将文本字段对齐到底部,从顶部对齐文本

如何从顶部和文本字段底部对齐文本?这是为了创建一种类似聊天的界面.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Retrieve Text Input'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.end,

          children: <Widget>[
            Text(
              'Hello, How are you?\nwow',
              textAlign: TextAlign.left,
              overflow: TextOverflow.ellipsis,
              //style: new TextStyle(fontWeight: FontWeight.bold),
            ),
            TextField(
              controller: myController,
              onChanged: (text) {
                //print("First text field: $text");
              },
              onSubmitted: (text) {
                print(text);
                //myController.clear();
                myController.text = "";
              },
              decoration: new InputDecoration(
                  hintText:"Enter your response."
              ),
              focusNode: _focusNode,
              autofocus: true,
            ),
          ],
        ),
      ),
    ); …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

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

AWS API Gateway websocket发送消息到连接

我正在尝试从 AWS API 网关 websocket 发回消息,该消息已路由到我的 lambda。

我目前能够检索 connectionID,但在使用 python 或 postman 将消息发送回连接时似乎遇到一些问题。

按照文档,我一直在向以下地址发送帖子请求:

https://<API_ID>.execute-api.ap-southeast-1.amazonaws.com/<STAGE>/@connections/<connectionID>
Run Code Online (Sandbox Code Playgroud)

谁能验证我是否正确执行此操作?我似乎得到以下回应

{
    "message": "Missing Authentication Token"
}
Run Code Online (Sandbox Code Playgroud)

是否应该有一个 Auth Token 可以解析为 websocket api?

amazon-web-services aws-api-gateway

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

在列表C++上执行递归

我试图确定我可以使用标准列表从列表中删除的最大项目数,以获得最小大小.但是,它最终会导致内存访问不良.

这是我的递归函数:

int step (list<int> mylist) {
    int count = mylist.size();
    // Terminations
    if (!checkRemaining(mylist)) {
        return mylist.size();
    }
    if (mylist.empty()) {
        return 0;
    }
    //printf("mysize: %d\n", mylist.size());

    // Else we do not terminate first
    for (auto i=mylist.begin(); i != prev(mylist.end()); ++i)
    {
        if ((*i + *next(i))%2 == 0) // Problem starts from here, bad access
        {
            mylist.erase(next(i));
            mylist.erase(i);
            printf("this size %lu\n", mylist.size());

            list<int> tempList = mylist;
            for (auto it = tempList.begin(); it != tempList.end(); it++) {
                printf("%d ", *it); …
Run Code Online (Sandbox Code Playgroud)

c++ recursion linked-list

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