在 PM::WebScreen 上显示来自 BubbleWrap 响应的内容
Display content on PM::WebScreen from BubbleWrap response
class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response
end
def on_load
set_nav_bar_button :left, title: "Menu", action: :nav_left_button
end
def load_started
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
end
def nav_left_button
app_delegate.menu.show(:left)
end
end
我需要发送带有特定 header 的 HTTP 请求,但内容总是 nil 。我已经通过嗅探器检查了响应 - 一切正常。
如果我这样做
class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
@response
end
我明白了
eb_screen_module.rb:50:in `set_content:': Is a directory - read() failed (Errno::EISDIR)
异常
NSUserDefaults.standardUserDefaults.registerDefaults({UserAgent: "value"})
自己找到解决方案
class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response
end
def on_load
set_nav_bar_button :left, title: "Menu", action: :nav_left_button
end
def load_started
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
end
def nav_left_button
app_delegate.menu.show(:left)
end
end
我需要发送带有特定 header 的 HTTP 请求,但内容总是 nil 。我已经通过嗅探器检查了响应 - 一切正常。
如果我这样做
class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
@response
end
我明白了
eb_screen_module.rb:50:in `set_content:': Is a directory - read() failed (Errno::EISDIR)
异常
NSUserDefaults.standardUserDefaults.registerDefaults({UserAgent: "value"})
自己找到解决方案