У меня есть 2 вкладки экраны,Как переключаться между закладках экранами swipeing
Я хочу красть право на второй вкладке экрана
и проведите пальцем влево на первой вкладке экрана
Но я не» t знать, как вызвать открытый экран второй вкладки в handle_swipe метод
Любая идея? Спасибо
AppDelegate
ruby class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) @window.makeKeyAndVisible first_tab = FirstTabController.alloc.init second_tab = SecondTabController.alloc.init @tabbar = UITabBarController.alloc.init @tabbar.viewControllers = [first_tab, second_tab] @tabbar.wantsFullScreenLayout = true @window.addSubview @tabbar.view
FirstTabController
`` `рубин
class FirstTabController < UIViewController
def init
if super
self.title = "First Tab"
self.tabBarItem.image = UIImage.imageNamed('FirstTab.png')
end
self
end
def viewDidLoad
view.backgroundColor = UIColor.whiteColor
@label = UILabel.new
@label.text = 'First Tab'
@label.frame = [[50,50],[250,50]]
view.addSubview(@label)
# right
recognizer = UISwipeGestureRecognizer.alloc.initWithTarget(self, action:'handle_swipe:')
self.view.addGestureRecognizer(recognizer)
# left
recognizer = UISwipeGestureRecognizer.alloc.initWithTarget(self, action:'handle_swipe:')
recognizer.direction = UISwipeGestureRecognizerDirectionLeft
self.view.addGestureRecognizer(recognizer)
end
def handle_swipe(sender)
if(sender.direction == UISwipeGestureRecognizerDirectionRight)
p "Swiped right"
# @secondary_controller = SecondaryController.alloc.init
@secondary_controller = SecondTabController.alloc.init
# self.navigationController.pushViewController(@secondary_controller, animated: true)
end
end
end
` ``
привет, я уже есть метод __handle_swipe__, но не знаете, как открыть другой __UIViewController__ here.what это синтаксис? спасибо – newBike
Большое спасибо, я нашел обходное решение, чтобы получить ti. – newBike