小编SHA*_*AIN的帖子

如何在IOS 14 swift中显示下拉按钮菜单

我创建了一个如下所示的下拉按钮

@IBOutlet weak var pullDownButton: UIButton!
Run Code Online (Sandbox Code Playgroud)

然后我从 viewDidLoad() 调用一个方法来配置下拉菜单引用

func setupMenu() {
    let add = UIAction(title: "Add", image: UIImage(systemName: "plus")) { _ in
        self.showToast(message: "Add", seconds: 1.0)
    }
    
    let edit = UIAction(title: "Edit", image: UIImage(systemName: "pencil")) { _ in
        self.showToast(message: "Edit", seconds: 1.0)
    }
    
    let delete = UIAction(title: "Delete", image: UIImage(systemName: "minus")) { _ in
        self.showToast(message: "Delete", seconds: 1.0)
    }
    
    let menu = UIMenu(title: "Menu", children: [add, edit, delete])
    pullDownButton.menu = menu
    pullDownButton.showsMenuAsPrimaryAction = true
}
Run Code Online (Sandbox Code Playgroud)

但我无法在长按或简单按下时显示下拉菜单。

有什么办法可以显示下拉菜单

swift ios14

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

在 SwiftUI 中以全屏模式呈现视图

我需要在 SwiftUI 中以全屏模式呈现一个视图。

在 UIKit 中,以下代码足以呈现UIViewController全屏模态:

let modalViewController = ModalViewController()
modalViewController.modalPresentationStyle = .fullScreen
present(modalViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

在 SwiftUI 中,我们使用sheet来进行模态视图呈现:

struct ContentView: View {
    @State private var showingSheet = false
    
    var body: some View {
        Button("Show Sheet") {
            showingSheet.toggle()
        }
        .sheet(isPresented: $showingSheet) {
            SecondView(name: "Imran")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在没有全屏呈现的情况下,工作表像卡片一样呈现视图,可以通过下拉视图来将其关闭。

我需要以全屏方式呈现模式视图,以便不能通过下拉将其关闭。

我怎样才能像我在之前的 UIKit 代码中所做的那样,使这个工作表模式演示全屏显示?

ios swift swiftui

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

github 提交显示全名而不是用户名

我通常使用gitbash在 github 中提交

当我提交时,它会显示我的用户名。

我的教授让我提交我的项目,在提交详细信息中显示我的全名

我通过在 Windows 中编辑.gitconfig文件尝试了一些解决方案。

我还尝试了Stack Overflow 的一些解决方案,如下所示:

git config --global user.name "name"
git config --global user.email "email"
Run Code Online (Sandbox Code Playgroud)

git config user.name "name"
git config user.email "email"
Run Code Online (Sandbox Code Playgroud)

但这对我不起作用。

github git-bash

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

如何在没有 Visual Studio 的 Windows 上的 cmd 中编译和运行 C/C++ MPI 代码

我安装 MS-MPI

我喜欢用 Sublime Text 编写代码,特别是 C/C++

我使用 gcc/g++ 在 cmd 中运行代码

我怎样才能编译并运行从 cmd 编译并运行 MPI 代码

我不喜欢视觉工作室

那么,有什么方法可以在 cmd 中使用 MS-MPI 编译和运行我的 C/C++ MPI 代码

我知道标题中有一个问题: Compile C++ MPI Code on Windows

但没有明确的答案或评论。这就是为什么我现在重新问

c c++ parallel-processing ms-mpi

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

如何在不关闭的情况下保存和读取c ++ fstream文件

我打开了文件的读写模式

使用以下语句

file.open(fileName, ios::in | ios::out | ios::trunc);
Run Code Online (Sandbox Code Playgroud)

在两种模式下打开文件的主要目的是同时读取和写入文件。

但是在我的代码场景中

当我在写入文件后读取文件时,输出显示空白,这表示未保存我的写入内容,因为我没有关闭文件。

我想在完成读写操作后关闭文件

我在Stack Overflow中找到了解决方案,

使用flush()函数保存文件而不关闭

file.flush();
Run Code Online (Sandbox Code Playgroud)

但是,问题是它不适用于我的情况

那么,如何在不关闭的情况下保存c ++ fstream文件?

这是我的完整代码,可让您更好地理解

#include <iostream>
#include <string>
#include <fstream>
using namespace std;


int main(int argc, char const *argv[])
{
    string fileName = "text.txt";

    fstream file;


    file.open(fileName, ios::in | ios::out | ios::trunc);

    if (file.is_open())
    {
        file << "I am a Programmer" << endl;
        file << "I love to play" << endl;
        file << "I love to work game and software development" …
Run Code Online (Sandbox Code Playgroud)

c++ fstream file

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

无法修复 Active Record 待迁移错误

我正在尝试制作一个演示 Restful json api

使用此链接:

https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-one

但是当我尝试运行以下命令时

$ bundle exec rspec

ActiveRecord::PendingMigrationError

error generated

i tried many solution available in stack overflow but no effect happen so far



C:\ruby\imran-api>bundle exec rspec
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:573:in `check_pending!':  (ActiveRecord::PendingMigrationError)

Migrations are pending. To resolve this issue, run:

        bin/rails db:migrate RAILS_ENV=test

        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:586:in `load_schema_if_pending!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `block in maintain_test_schema!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:823:in `suppress_messages'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:597:in `method_missing'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `maintain_test_schema!'
        from C:/ruby/imran-api/spec/rails_helper.rb:27:in `<top (required)>'
        from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `require'
        from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `<top (required)>'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in …
Run Code Online (Sandbox Code Playgroud)

rest activerecord json rspec ruby-on-rails-5

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

如何删除Unity3d中的切片精灵

当我在Unity中切片精灵时.

我错误地切了一块我不想要的东西

这里是Menu Buttons_0

在此输入图像描述

现在,我想删除那些垃圾

有什么办法可以删除菜单按钮_0

sprite game-development game-engine unity-game-engine

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

在我自己的堆栈中实现top的问题

我正在尝试实现我自己的通用堆栈

实现Top Function存在一些问题,它返回堆栈的最后一个元素

但是当head == NULL时,没有什么可以返回的

#include <iostream>
#include <string>
using namespace std;

template <class anyType>
class Stack
{
    private: struct node
    {
        anyType data;
        node* nextAddress;
    };

    private: node* head;

    public: Stack()
    {
        head = NULL;
    }

    public: anyType Top()
    {
        if (head == NULL)
        {
            cout<<"Stack is empty"<<endl;

            return NULL;
        }

        node* travel = head;

        while(travel -> nextAddress != NULL)
        {
            travel = travel -> nextAddress;
        }

        return travel -> data;
    }

};


struct Student
{ …
Run Code Online (Sandbox Code Playgroud)

c++ stack

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

在python中使用for循环的系列求和

让我们假设这个系列

1+2+3+....+n
Run Code Online (Sandbox Code Playgroud)

在带有for循环的c中,我们可以轻松完成此操作

for(i=1;i<=n;i++)
{
    sum += i;
}
Run Code Online (Sandbox Code Playgroud)

python我能够使用while循环完成此操作

while(num <= n):

      sum += num
      num = num+1
Run Code Online (Sandbox Code Playgroud)

但我无法使用python for循环来做到这一点

python for-loop python-3.x

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