草庐IT

ios - 使用快速滑动的 View 创建 pagingmenucontroller

coder 2023-09-09 原文

我正在创建一个聊天应用程序,其中有一些具有不同类别的预定义常见问题解答,当用户单击按钮时它们会向上滑动。以下是图片的外观:

[![最终输出]

我正在使用来自以下链接的 PagingMenucontroller 库: https://github.com/kitasuke/PagingMenuController

我面临的问题是 View 不占用设备的宽度。 uitableview 的滚动不起作用。 数据也是免费的,业务部分只会被加载。

以下是上图中父类ChatViewcontroller的代码:

    import Foundation
import UIKit
import PagingMenuController

class ChatViewController: UIViewController, UITextFieldDelegate//, UITableViewDelegate, UITableViewDataSource
{

    @IBOutlet var askQuestionTxtField: UITextField!
    @IBOutlet var bottomTypingView: UIView!

    @IBOutlet var bottomQuestionsView: UIView!
    @IBOutlet var chatView: UIView!
    var questionViewYPos:CGFloat = 0.0
    var keyboardFrame:CGRect = CGRect(x: 0, y: 0, width: 0, height: 0)
    @IBOutlet var questionOpenBtn: UIButton!

    @IBOutlet var questionViewBottomConstraint: NSLayoutConstraint!
    var isQuestionViewOpen:Bool = false
    var isKeyboardVisible:Bool = false
    var timer = NSTimer()
    var questionCategoriesArray:[String] = ["FREE", "BUSINESS", "RELATIONSHIPS", "CAREER", "OTHERS"]
    var questionsDictionary:Dictionary<String,[String]> = [:]

    @IBAction func onQuestionViewBtnClick(sender: AnyObject)
    {
        if(isKeyboardVisible)
        {
            animateViewMoving(false, moveValue: questionViewYPos-bottomTypingView.frame.size.height)
            bottomQuestionsView.hidden = false
            askQuestionTxtField.resignFirstResponder()

            timer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(0.4), target: self, selector: "openQuestionView", userInfo: nil, repeats: false)
        }
        else
        {
            isQuestionViewOpen = !isQuestionViewOpen
            print("isQuestionViewOpen",isQuestionViewOpen)
            print("bottomQuestionsView height :: ",bottomQuestionsView.frame.size.height)
            if(isQuestionViewOpen)
            {
                questionViewAnimation(true, moveValue: (questionViewYPos))
                animateViewMoving(true, moveValue: (questionViewYPos))
            }
            else
            {

                animateViewMoving(false, moveValue: (questionViewYPos))
            }
        }
    }

    func openQuestionView()
    {
        isQuestionViewOpen = !isQuestionViewOpen
        questionViewAnimation(true, moveValue: (questionViewYPos))
        animateViewMoving(true, moveValue: (questionViewYPos))
    }

    @IBAction func onFreeBtnClick(sender: AnyObject)
    {
        print("onFreeBtnClick")
    }
    @IBAction func onBusinessBtnClick(sender: AnyObject)
    {
        print("onBusinessBtnClick")
    }
    @IBAction func onRelationshipBtnClick(sender: AnyObject)
    {
        print("onRelationshipBtnClick")
    }
    @IBAction func onCareerBtnClick(sender: AnyObject)
    {
        print("onCareerBtnClick")
    }
    @IBAction func onOthersBtnClick(sender: AnyObject)
    {
        print("onOthersBtnClick")
    }
    var freeItems: [String] = ["What Shall I keep in mind about money 1", "Heart shall I keep in mind", "What shall I keep in mind about money \n matters today?","We keep in mind about money 2","We keep in mind about money 3", "We keep in mind about money 4", "Heart shall I keep in mind 2", "Heart shall I keep in mind 3"]

    var businessItems: [String] = ["What is my Business Future 1", "What is my Business Future 2", "What is my Business Future 3 \n and other matters today?","What is my Business Future 4","What is my Business Future 5", "What is my Business Future 6", "What is my Business Future 7", "What is my Business Future 8","What is my Business Future 9", "What is my Business Future 10"]

    var relationShipsItems: [String] = ["How Will be my RelationShip this Year 1", "How Will be my RelationShip this Year 2", "How Will be my RelationShip today \n and other matters","How Will be my RelationShip this Year 3","How Will be my RelationShip this week 4", "How Will be my RelationShip this Year 5", "How Will be my RelationShip this Year 6", "How Will be my RelationShip tomorrow 7", "How Will be my RelationShip this Year 8"]

    var careerItems: [String] = ["How will be my career 1", "How will be my career 2", "How will be my career 3","We keep in mind about money 2","How will be my career 4", "How will be my career 5", "How will be my career 6", "How will be my career 7","How will be my career 8","How will be my career 9","How will be my career 10","How will be my career 11","How will be my career 12","How will be my career 13", "How will be my career 14","How will be my career 15"]

    var otherItems: [String] = ["Other Future Related Questions 1", "Other Future Related Questions 2", "Other Future Related Questions 3", "Other Future Related Questions 4", "Other Future Related Questions 5", "Other Future Related Questions 6", "Other Future Related Questions 7", "Other Future Related Questions 8", "Other Future Related Questions 9", "Other Future Related Questions 10", "Other Future Related Questions 11", "Other Future Related Questions 12", "Other Future Related Questions 13", "Other Future Related Questions 14", "Other Future Related Questions 15", "Other Future Related Questions 16", "Other Future Related Questions 17", "Other Future Related Questions 18", "Other Future Related Questions 19", "Other Future Related Questions 20"]
    var questionsVariableArray:[[String]]!

    override func viewDidLoad() {
        super.viewDidLoad()
        //NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification)

        NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardDidShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
        bottomQuestionsView.userInteractionEnabled = true
        askQuestionTxtField.delegate = self
        questionViewYPos = self.chatView.frame.size.height-(self.chatView.frame.size.height - bottomQuestionsView.frame.size.height)
        print("bottomQuestionsView.frame.origin.y",bottomQuestionsView.frame.origin.y)
        print("pos :: ",questionViewYPos)

        self.questionsVariableArray  = [self.freeItems, self.businessItems, self.relationShipsItems, self.careerItems, self.otherItems]
        print("self.questionsVariableArray  ::",self.questionsVariableArray )
        print("self.freeItems  ::",self.freeItems)
        print("self.businessItems  ::",self.businessItems)
        print("self.relationShipsItems  ::",self.relationShipsItems )
        print("self.careerItems  ::",self.careerItems )
        print("self.otherItems  ::",self.otherItems )

        createQuestionsDictionary()

    }

    func createQuestionsDictionary()
    {
        for(var i:Int = 0;i < self.questionCategoriesArray.count; i++)
        {
            print("self.questionCategoriesArray[i] :: ",self.questionCategoriesArray[i])
            print("self.questionsVariableArray[i] :: ",self.questionsVariableArray[i])
            questionsDictionary[self.questionCategoriesArray[i]] = self.questionsVariableArray[i]
        }

        print("questionsDictionary :: ",questionsDictionary)
        loadCategoriesQuestionsView()
    }

    func loadCategoriesQuestionsView()
    {
        var viewControllersArray:[ChatQuestionsViewController] = []
        /*for(var i:Int = 0; i < self.questionCategoriesArray.count; i++)
        {
            let _viewController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

            _viewController.title = self.questionCategoriesArray[i]
            Constants.questionCategoriesArray = self.questionCategoriesArray
            Constants.questionsDictionary = self.questionsDictionary

            _viewController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[i])
            viewControllersArray.append(_viewController)
            _viewController.view.translatesAutoresizingMaskIntoConstraints = true
        }*/

        let _freeviewController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

        _freeviewController.title = self.questionCategoriesArray[0]
        Constants.questionCategoriesArray = self.questionCategoriesArray
        Constants.questionsDictionary = self.questionsDictionary

        viewControllersArray.append(_freeviewController)
        //_freeviewController.view.translatesAutoresizingMaskIntoConstraints = true

        let _businessviewController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

        _businessviewController.title = self.questionCategoriesArray[1]
        Constants.questionCategoriesArray = self.questionCategoriesArray
        Constants.questionsDictionary = self.questionsDictionary

        viewControllersArray.append(_businessviewController)
        //_freeviewController.view.translatesAutoresizingMaskIntoConstraints = true

        let _relationshipController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

        _relationshipController.title = self.questionCategoriesArray[2]
        Constants.questionCategoriesArray = self.questionCategoriesArray
        Constants.questionsDictionary = self.questionsDictionary

        viewControllersArray.append(_relationshipController)
        //_freeviewController.view.translatesAutoresizingMaskIntoConstraints = true

        let _careerController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

        _careerController.title = self.questionCategoriesArray[3]
        Constants.questionCategoriesArray = self.questionCategoriesArray
        Constants.questionsDictionary = self.questionsDictionary

        viewControllersArray.append(_careerController)
        //_freeviewController.view.translatesAutoresizingMaskIntoConstraints = true

        let _otherController = ChatQuestionsViewController.init(nibName: "ChatQuestionsViewController", bundle: nil)

        _otherController.title = self.questionCategoriesArray[4]
        Constants.questionCategoriesArray = self.questionCategoriesArray
        Constants.questionsDictionary = self.questionsDictionary

        viewControllersArray.append(_otherController)
        //_freeviewController.view.translatesAutoresizingMaskIntoConstraints = true



        let options = PagingMenuOptions()
        options.menuItemMargin = 5
        //options.menuDisplayMode = .SegmentedControl
        let pagingMenuController = PagingMenuController(viewControllers: viewControllersArray , options: options)
        self.addChildViewController(pagingMenuController)
        self.bottomQuestionsView.addSubview(pagingMenuController.view)

        //self.bottomQuestionsView.translatesAutoresizingMaskIntoConstraints = true
        //self.bottomQuestionsView.translatesAutoresizingMaskIntoConstraints = true
        pagingMenuController.didMoveToParentViewController(self)

        if _freeviewController.isViewLoaded()
        {
            // viewController is visible
            _freeviewController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[0])
            //_freeviewController.chatTableView.reloadData()
        }
        if _businessviewController.isViewLoaded()
        {
            // viewController is visible
            _businessviewController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[1])
            //_businessviewController.chatTableView.reloadData()

        }
        if _relationshipController.isViewLoaded()
        {
            // viewController is visible
            _relationshipController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[2])
            //_relationshipController.chatTableView.reloadData()
        }
        if _careerController.isViewLoaded()
        {
            // viewController is visible
            _careerController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[3])
            //_careerController.chatTableView.reloadData()
        }
        if _otherController.isViewLoaded()
        {
            // viewController is visible
            _otherController.setQuestionsCategoryArray(self.questionCategoriesArray, _questionsDictionary: self.questionsDictionary, _categoryName: self.questionCategoriesArray[4])
            //_otherController.chatTableView.reloadData()
        }
    }

    func textFieldDidBeginEditing(textField: UITextField)
    {
        print("keyboardFrame.size.height",self.view.frame.origin.y)
        //animateViewMoving(true, moveValue: questionViewYPos-bottomTypingView.frame.size.height)

        if(self.view.frame.origin.y < 0.0)
        {
            animateViewMoving(false, moveValue: (questionViewYPos))
            timer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(0.4), target: self, selector: "update", userInfo: nil, repeats: false)
            isQuestionViewOpen = !isQuestionViewOpen
            print("isQuestionViewOpen ###",isQuestionViewOpen)
        }
        else
        {
            animateViewMoving(true, moveValue: questionViewYPos-bottomTypingView.frame.size.height)
            bottomQuestionsView.hidden = true
        }


    }
    func update() {
        // Something cool
        animateViewMoving(true, moveValue: questionViewYPos-bottomTypingView.frame.size.height)
         bottomQuestionsView.hidden = true
    }

    func textFieldDidEndEditing(textField: UITextField)
    {
        //animateViewMoving(false, moveValue: questionViewYPos-bottomTypingView.frame.size.height)
        textField.resignFirstResponder()
    }

    func textFieldShouldReturn(textField: UITextField) -> Bool
    {
        //isQuestionViewOpen = !isQuestionViewOpen
        animateViewMoving(false, moveValue: questionViewYPos-bottomTypingView.frame.size.height)
        bottomQuestionsView.hidden = false
        //bottomQuestionsView.translatesAutoresizingMaskIntoConstraints = true
        textField.resignFirstResponder()

        return true
    }

    /*func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return self.freeItems.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        //var cell:UITableViewCell = self.chatTableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
        let cellIdentifier = "cell"
        let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! ChatCellView

        let cellTxtString = freeItems[indexPath.row]

        cell.questionNoLbl.text = String(indexPath.row + 1)
        cell.questionLbl.text = cellTxtString
        return cell
    }

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
    {

    }

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }*/

    func animateViewMoving (up:Bool, moveValue :CGFloat){
        let movementDuration:NSTimeInterval = 0.3
        let movement:CGFloat = ( up ? -moveValue : moveValue)
        UIView.beginAnimations( "animateView", context: nil)
        UIView.setAnimationBeginsFromCurrentState(true)
        UIView.setAnimationDuration(movementDuration )
        self.view.frame = CGRectOffset(self.view.frame, 0,  movement)
        UIView.commitAnimations()
    }

    func questionViewAnimation(up:Bool, moveValue: CGFloat)
    {
        let movementDuration:NSTimeInterval = 0.3
        let movement:CGFloat = ( up ? -moveValue : moveValue)
        UIView.beginAnimations( "animateView", context: nil)
        UIView.setAnimationBeginsFromCurrentState(true)
        UIView.setAnimationDuration(movementDuration )
        self.bottomQuestionsView.frame = CGRectOffset(self.bottomQuestionsView.frame, 0,  movement)

        UIView.commitAnimations()
    }


    func keyboardWillShow(notification: NSNotification) {
        keyboardFrame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
        print("keyboardFrame",keyboardFrame.height)
        isKeyboardVisible = true
        // do stuff with the frame...
    }

    func keyboardWillHide(notification: NSNotification) {
        keyboardFrame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
        print("keyboardFrame",keyboardFrame.height)
        isKeyboardVisible = false
        // do stuff with the frame...
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

以下是连接到具有 TableView 的 xib 的聊天问题 View Controller 的代码:

import UIKit
class ChatQuestionsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
{   
    @IBOutlet var chatTableView: UITableView!

    var categoryArray:[String]!
    var categoryName:String = ""
    var questionsDictionary:Dictionary<String,[String]> = [:]
    var categoryQuestion:[String] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        print("self.chatTableView :: ",chatTableView)

        self.chatTableView.registerNib(UINib(nibName: "ChatQuestionCellRowView", bundle: nil), forCellReuseIdentifier: "cell")

        self.categoryArray = Constants.questionCategoriesArray
        self.questionsDictionary = Constants.questionsDictionary

        self.view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]

    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code

    }


    func setQuestionsCategoryArray(_categoryArray: [String], _questionsDictionary:Dictionary<String,[String]>, _categoryName:String)
    {
        //self.categoryArray = _categoryArray
        self.categoryName = _categoryName
        //self.questionsDictionary = _questionsDictionary
        //self.chatTableView.delegate = self
        //self.chatTableView.dataSource = self
        self.chatTableView.reloadData()
    }

    // MARK: - UITableViewDataSource

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        print("self.categoryName :: ",self.categoryName)
        if self.categoryName == ""
        {
            return 0
        }
        else
        {
            categoryQuestion = self.questionsDictionary[self.categoryName]!
            print("categoryQuestion count :: ",categoryQuestion.count)
            return categoryQuestion.count
        }

    }

    // MARK: - UITableViewDelegate

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! ChatCellView

        //let repository = self.categoryArray[indexPath.row]
        cell.questionNoLbl.text = String(indexPath.row)
        cell.questionLbl.text = categoryQuestion[indexPath.row]
        //cell.questionLbl.text = repository["name"] as? String
        return cell
    }

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)

        /*let detailViewController = storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as! DetailViewController
        navigationController?.pushViewController(detailViewController, animated: true)*/
    }

    func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }

}

还有用于 uitableview 的自定义单元格,下面是代码:

import UIKit

class ChatCellView: UITableViewCell
{

    @IBOutlet var questionNoLbl: UILabel!
    @IBOutlet var questionLbl: UILabel!


}

我的输出如下图所示:

[![当前输出图像]

我也无法点击免费业务等类别名称。

很抱歉发了这么长的帖子,但无法找出过去 3 天的解决方案。

更新: 上传 Storyboard及其层的截图

[![主 Storyboard]

最佳答案

在这里,我对项目 PagingMenuController 进行了更改,并根据需要创建了一个 UI。

这是演示项目,您可以查看!

What I have done?

我刚刚将 ContainerView 的约束更改为您想要的特定高度。

并确保您已为其 ChildViewController 提供适当的约束。

项目下载链接:https://www.dropbox.com/s/zili4l7yot7dnvo/Example.zip?dl=0

Answer Update

如果你用的是Autolayout那么你可以用frame来改变约束,肯定会报错。如果您想要更改,则可以通过以下方式进行:

questionViewBottomConstraint.constant = 250.0 //any value (here you can use `UITableView` height)

OR

questionViewBottomConstraint.constant = -250.0

相应地更改约束值并查看差异。

如果您需要任何更改,请告诉我!

关于ios - 使用快速滑动的 View 创建 pagingmenucontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34772287/

有关ios - 使用快速滑动的 View 创建 pagingmenucontroller的更多相关文章

  1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

    我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

  2. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  3. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  4. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  5. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  6. ruby - 如何在 Ruby 中顺序创建 PI - 2

    出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits

  7. ruby - 使用 ruby​​ 和 savon 的 SOAP 服务 - 2

    我正在尝试使用ruby​​和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我

  8. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  9. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  10. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

随机推荐