mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-05-28 23:50:54 +08:00
Merge pull request #174 from clearsightstudio/add-pop_to_root
PR: Allow popping to the root view controller in the nav stack.
This commit is contained in:
@@ -14,7 +14,7 @@ module ProMotion
|
||||
self.split_screen.detail_screen = screen
|
||||
|
||||
elsif args[:in_master] && self.split_screen
|
||||
self.split_screen.master_screen = screen
|
||||
self.split_screen.master_screen = screen
|
||||
|
||||
elsif args[:close_all]
|
||||
open_root_screen screen
|
||||
@@ -94,7 +94,7 @@ module ProMotion
|
||||
|
||||
# Instantiate screen if given a class
|
||||
screen = screen.new if screen.respond_to?(:new)
|
||||
|
||||
|
||||
# Set parent
|
||||
screen.parent_screen = self if screen.respond_to?(:parent_screen=)
|
||||
|
||||
@@ -151,7 +151,9 @@ module ProMotion
|
||||
|
||||
def close_nav_screen(args={})
|
||||
args[:animated] = true unless args.has_key?(:animated)
|
||||
if args[:to_screen] && args[:to_screen].is_a?(UIViewController)
|
||||
if args[:to_screen] == :root
|
||||
self.navigation_controller.popToRootViewControllerAnimated args[:animated]
|
||||
elsif args[:to_screen] && args[:to_screen].is_a?(UIViewController)
|
||||
self.parent_screen = args[:to_screen]
|
||||
self.navigation_controller.popToViewController(args[:to_screen], animated: args[:animated])
|
||||
else
|
||||
|
||||
@@ -73,7 +73,7 @@ module ProMotion
|
||||
data_cell[:cell_style] ||= UITableViewCellStyleDefault
|
||||
data_cell[:cell_class] ||= PM::TableViewCell
|
||||
data_cell[:cell_identifier] ||= build_cell_identifier(data_cell)
|
||||
|
||||
|
||||
data_cell[:accessory] = {
|
||||
view: data_cell[:accessory],
|
||||
value: data_cell[:accessory_value],
|
||||
|
||||
@@ -104,10 +104,10 @@ module ProMotion
|
||||
|
||||
table_cell
|
||||
end
|
||||
|
||||
|
||||
def create_table_cell(data_cell)
|
||||
table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier])
|
||||
|
||||
|
||||
unless table_cell
|
||||
data_cell[:cell_style] ||= UITableViewCellStyleSubtitle
|
||||
table_cell = data_cell[:cell_class].alloc.initWithStyle(data_cell[:cell_style], reuseIdentifier:data_cell[:cell_identifier])
|
||||
|
||||
@@ -90,4 +90,24 @@ describe "ProMotion::Screen functional" do
|
||||
end
|
||||
end
|
||||
|
||||
it "should pop to the root view controller" do
|
||||
@root_vc = @controller.navigation_controller.visibleViewController
|
||||
@controller.navigation_controller.viewControllers.count.should == 1
|
||||
@controller.open BasicScreen.new
|
||||
wait 0.6 do
|
||||
@controller.open BasicScreen.new
|
||||
wait 0.6 do
|
||||
@controller.open BasicScreen.new
|
||||
wait 0.6 do
|
||||
@controller.navigation_controller.viewControllers.count.should == 4
|
||||
@controller.close to_screen: :root
|
||||
wait 0.6 do
|
||||
@controller.navigation_controller.viewControllers.count.should == 1
|
||||
@controller.navigation_controller.topViewController.should == @root_vc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -56,6 +56,7 @@ describe "PM::TableViewCellModule" do
|
||||
it "should have the right custom re-use identifier" do
|
||||
@subject.reuseIdentifier.should == "Custom Cell"
|
||||
end
|
||||
|
||||
it "should have the right generated re-use identifier" do
|
||||
ip = NSIndexPath.indexPathForRow(2, inSection: 1)
|
||||
subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: ip)
|
||||
|
||||
Reference in New Issue
Block a user