对于如何使用Swift在iOS中从右到左显示视图控制器感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解swift左右滑动,并且为您提供关于html–括号显示错误地从右到左显示风格、ios–S
对于如何使用Swift在iOS中从右到左显示视图控制器感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解swift左右滑动,并且为您提供关于html – 括号显示错误地从右到左显示风格、ios – Swift 4 – 隐藏视图控制器的导航栏、ios – Swift segue – 不鼓励在分离的视图控制器上显示视图控制器、ios – Swift – 从完成块中解除视图控制器的宝贵知识。
本文目录一览:- 如何使用Swift在iOS中从右到左显示视图控制器(swift左右滑动)
- html – 括号显示错误地从右到左显示风格
- ios – Swift 4 – 隐藏视图控制器的导航栏
- ios – Swift segue – 不鼓励在分离的视图控制器上显示视图控制器
- ios – Swift – 从完成块中解除视图控制器
如何使用Swift在iOS中从右到左显示视图控制器(swift左右滑动)
我正在使用presentViewController呈现新屏幕
let dashboardWorkout = DashboardWorkoutViewController()presentViewController(dashboardWorkout, animated: true, completion: nil)
这将显示从下到上的新屏幕,但我希望不使用即可从右到左显示UINavigationController
。
我使用的是Xib而不是情节提要,该怎么办?
答案1
小编典典是否使用xib
或storyboard
正在使用都没有关系。通常,当您将视图控制器推入Presentor时,使用从右向左过渡UINavigiationController
。
更新
新增计时功能 kCAMediaTimingFunctionEaseInEaseOut
示例项目与 斯威夫特4
实现加入GitHub上
迅捷3和4.2
let transition = CATransition()transition.duration = 0.5transition.type = CATransitionType.pushtransition.subtype = CATransitionSubtype.fromRighttransition.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)view.window!.layer.add(transition, forKey: kCATransition)present(dashboardWorkout, animated: false, completion: nil)
对象
CATransition *transition = [[CATransition alloc] init];transition.duration = 0.5;transition.type = kCATransitionPush;transition.subtype = kCATransitionFromRight;[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];[self.view.window.layer addAnimation:transition forKey:kCATransition];[self presentViewController:dashboardWorkout animated:false completion:nil];
斯威夫特2.x
let transition = CATransition()transition.duration = 0.5transition.type = kCATransitionPushtransition.subtype = kCATransitionFromRighttransition.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut)view.window!.layer.addAnimation(transition, forKey: kCATransition)presentViewController(dashboardWorkout, animated: false, completion: nil)
在自定义转换的情况下,方法中的animated
参数presentViewController
似乎并不重要。它可以是任何值,true
或者false
。
html – 括号显示错误地从右到左显示风格
<html dir="rtl"> <p>hello (world)</p> </html>
你会看到这样一个页面:
(hello (world
但是,如果我将HTML代码更改为
<html dir="rtl"> <p>hello (world) again</p> </html>
然后文本正常显示:
hello (world) again
任何人都可以解释为什么会发生这种情况?
第一个例子如何解决?
我的浏览器是chrome
解决方法
<html dir="rtl"> <body> <p>hello (world)‎</p> </body></html>
这告诉浏览器将括号解释为从左到右的读数.
ios – Swift 4 – 隐藏视图控制器的导航栏
这是我在第一个vc中使用的代码:
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Hide the Navigation Bar self.navigationController?.setNavigationBarHidden(true,animated: animated) } override func viewWilldisappear(_ animated: Bool) { super.viewWilldisappear(animated) // Show the Navigation Bar self.navigationController?.setNavigationBarHidden(false,animated: animated) }
swift 4有什么变化?该代码在swift 3中有效…
解决方法
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(true) // Show the Navigation Bar self.navigationController?.setNavigationBarHidden(true,animated: true) } override func viewWilldisappear(_ animated: Bool) { super.viewWilldisappear(true) // Hide the Navigation Bar self.navigationController?.setNavigationBarHidden(false,animated: false) }
我认为你在动画中做错了:是的
ios – Swift segue – 不鼓励在分离的视图控制器上显示视图控制器
let selectedCityId = NSUserDefaults.standardUserDefaults().integerForKey("selectedCityId") if(selectedCityId == 0){ self.performSegueWithIdentifier("startupSegue",sender: self) } else { .... }
所以startupSegue以模态方式打开settingsViewController(SettingsVC)!两者 – MainVC和SettingsVC都嵌入了导航视图控制器.
有2个警告:
Presenting view controllers on detached view controllers is
discouraged “myapp.MainVC: 0x7fee8871e670”.Unbalanced calls to begin/end appearance transitions for
“UINavigationController: 0x7fee8872c950”.
谢谢你的回答.
解决方法
ios – Swift – 从完成块中解除视图控制器
@IBAction func facebookLoginTapped(sender: AnyObject) { // let ref = Firebase(url: "https://XXXX.firebaseio.com") let facebookLogin = FBSDKLoginManager() facebookLogin.logInWithReadPermissions(["email"],fromViewController: self,handler: { (facebookResult,facebookError) -> Void in if facebookError != nil { print("Facebook login Failed. Error \(facebookError)") } else if facebookResult.isCancelled { print("Facebook login was cancelled.") } else { //successfully logged in //get facbook access token let accesstoken = FBSDKAccesstoken.currentAccesstoken().tokenString //use access token to authenticate with firebase ref.authWithOAuthProvider("facebook",token: accesstoken,withCompletionBlock: { error,authData in if error != nil { print("Login Failed. \(error)") } else { //authData contains print("Logged in! \(authData)") //pop loginvc back to uservc - DO I NEED TO GET MAIN THREAD HERE BEFORE disMISSING VIEW CONTROLLER self.dismissViewControllerAnimated(true,completion: nil) } }) } }) }
解决方法
self.dismissViewControllerAnimated(true,completion:nil)就像这样……
Swift 2.x
dispatch_async(dispatch_get_main_queue()){ self.dismissViewControllerAnimated(true,completion: nil) }
Swift 3&斯威夫特4:
dispatchQueue.main.async { self.dismiss(animated: true,completion: nil) }
关于如何使用Swift在iOS中从右到左显示视图控制器和swift左右滑动的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于html – 括号显示错误地从右到左显示风格、ios – Swift 4 – 隐藏视图控制器的导航栏、ios – Swift segue – 不鼓励在分离的视图控制器上显示视图控制器、ios – Swift – 从完成块中解除视图控制器等相关内容,可以在本站寻找。
本文标签: