1

I'm using ProMotion, BubbleWrap, Teacup, and GeoMotion. Having trouble finding the distance from the CGRectMake origin for the navbar to the right edge of the screen. I'd like to fit both portrait and landscape. Also having trouble putting a navbar across the whole top of the split screens, but I will settle to fix this problem first. Thank you.

Using Sublime text editor, the autocomplete seems to show me all available methods, no matter what I'm calling them on.

class AppDelegate < PM::Delegate
  include PM::Styling
  status_bar true, animation: :none

  def on_load(app, options)
    open_split_screen MenuScreen, DetailScreen

  end

  def set_appearance_defaults
    UINavigationBar.appearance.tintColor = hex_color("61B637")
  end
end

class MenuScreen < PM::TableScreen
  searchable placeholder: "Search states"

  title "Menu"

  def table_data
    [{
      title: "",
      cells: Menu.all.map { |state| { title: state.name, action: :tapped_state } }
    }]
  end

  def tapped_state(args={})
    PM.logger.debug args
  end

  def states_tapped
  end

  def help_tapped
  end
end

class DetailScreen < PM::Screen
  include DetailStyles

  title "Detail"

  def on_load
    #UIScreen.mainScreen.bounds ???
    width = ???
    naviBarObj = UINavigationBar.alloc.initWithFrame(CGRectMake(0, 0, width, 44))
    self.view.addSubview(naviBarObj)
    cancelItem = UIBarButtonItem.alloc.
      initWithTitle("Cancel", 
      style:UIBarButtonItemStyleBordered, 
      target:self, 
      action:'cancelButtonPressed')
    doneItem = UIBarButtonItem.alloc.
      initWithTitle("Done", 
      style:UIBarButtonItemStyleBordered, 
      target:self, 
      action:'doneButtonPressed')

    navigItem = UINavigationItem.alloc.initWithTitle("Navigation Title")
    navigItem.rightBarButtonItem = doneItem
    navigItem.leftBarButtonItem = cancelItem
    naviBarObj.items = NSArray.arrayWithObjects(navigItem, nil)




    self.view.backgroundColor = BW.rgb_color(100, 150, 50)
  end
  def cancelButtonPressed
    true
  end
  def doneButtonPressed
    true 
  end

  def states_tapped
    true
  end

  def help_tapped
    true
  end
end
4

1 回答 1

1

如果您试图让视图在详细信息屏幕上展开:

self.view.frame.size.width

如果您试图在整个屏幕上显示它:

UIScreen.mainScreen.bounds.size.width

但我实际上建议您将详细视图控制器设为导航控制器(因为我很确定您希望在详细视图中导航)然后将 ACTUAL 详细视图控制器作为您当前拥有的详细视图控制器,然后导航栏将为您处理。

最后一个选项,正如我看到的那样,您正在使用“完成”和“取消”,您实际上可能想要一个模式视图,而不是导航控制器。如果您想要显示某些内容,然后被取消或完成某个操作所解雇,那么模态视图就是您的选择。

于 2013-12-15T01:29:07.180 回答