闪亮的Widget中的uiOutput渲染:: dropdownButton

时间:2018-08-30 09:36:13

标签: r shiny

我在uiOutput中有一个shinyWidget::dropdownButton。我的问题是,在单击下拉按钮之前,取决于uiOutput中控件的输出不会呈现。

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  dropdownButton(uiOutput("placeholder"), icon = icon("cog")),
  verbatimTextOutput("out")
)

server <- function(input, output) {
   output$placeholder <- renderUI(selectInput("dat", "Select Data:",
                             choices = c("mtcars", "ChickWeight")))
   output$out <- renderPrint(summary(get(req(input$dat))))
}

shinyApp(ui, server)

在此应用程序中,您看到仅在我第一次单击下拉按钮后才显示摘要表。从反应流中,我认为这是有道理的,但是我想知道如何强制uiOutput进行渲染(以便随后的out逐字逐句渲染)?

1 个答案:

答案 0 :(得分:2)

您可以这样做:

UIGraphicsBeginImageContextWithOptions(CGSize(width: UIScreen.main.bounds.width, height: 200) , false, 0)
let cellRect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 200)
view.drawHierarchy(in: cellRect, afterScreenUpdates: true)
let wholeImage = UIGraphicsGetImageFromCurrentImageContext()//stretched image
UIGraphicsEndImageContext()
相关问题