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
If you're trying to get the a view stretched across the detail screen:
self.view.frame.size.width
If you're trying to get it across the whole screen:
UIScreen.mainScreen.bounds.size.width
But what I'd actually suggest is that you make the detail view controller a navigation controller (as I'm pretty sure you want navigation within the detail view) then have the ACTUAL detail view controller as your detail view controller that you have currently, then the navbar will be handled for you.
Last option, as I see you're using "Done" and "Cancel", you might actually be wanting a modal view, not a navigation controller. If you want something to show, then be dismissed from cancelling or from completing an action, a modal view is the way to go.