- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我是 Swift 的新手,所以我只是在学习。我正在关注 youtube 上的教程,但我一直收到此错误。让我们构建那个应用程序:如何构建 Twitter。“应用程序窗口应该在应用程序启动结束时有一个 Root View Controller ”
对于 window?.rootViewController = UINavigationController
它说
cannot assign value of type 'UINavigationController' to type UIViewController?' Expression of type'(rootViewController: HomeController)' is unused
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// ignore storyboard.
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let homeController = HomeContoller(collectionViewLayout:
UICollectionViewFlowLayout())
window?.rootViewController = UINavigationController
(rootViewController: homeController)
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
最佳答案
删除这两行之间的换行符:
window?.rootViewController = UINavigationController
(rootViewController: homeController)
第一行:
window?.rootViewController = UINavigationController
产生这个错误:
Cannot assign value of type 'UINavigationController.Type' to type 'UIViewController?'
第二行:
(rootViewController: homeController)
产生这个警告:
Expression of type '(rootViewController: HomeController)' is unused
如果你删除换行符,两者都会消失:
window?.rootViewController = UINavigationController(rootViewController: homeController)
关于ios - Swift 无法分配类型为 'UINavigationController' 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44848242/
我有几个由导航 Controller 控制的 View Controller 。 例如,viewController A 和 viewController B 都可以将 viewController
目前我在单独的 Storyboard中有一个导航 Controller ,它使用退出按钮。这个退出按钮应该返回到 rootViewController(那是在 mainstoryboard 中)这是一
我目前正在将我的应用程序迁移到 iOS 7 上,并且在新的导航 Controller /栏管理上已经卡了好几个小时了。 之前,当我们有导航 Controller 时,我们有这样的代码片段: UINav
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我使用 320*44 图像自定义 NavigationBar backgroundImage。因此状态栏为黑色。这就是我想要的。但是,当我呈现此 navigationController 时,如您所知
我正面临以下代码的崩溃。场景是 这是我的应用委托(delegate)方法,我在其中使用 UINavigationController 加载 RTC_HomeVC。 - (BOOL)applicatio
目前我有一个使用 uinavigationcontroller 但仅在 Root View 中隐藏导航栏的应用程序,我想在某些应用程序中将此应用程序用作外部库并将整个应用程序作为一个菜单项推送。 但是
我有两个 View Controller ,ViewControllerA 和 ViewControllerB,嵌入在 UINavigationController 中。 ViewController
iOS 7 采用了一种新手势,在屏幕上从左到右滑 Action 为 UINavigationController 中返回按钮的快捷方式。 我的应用似乎没有免费采用这种行为。我需要做什么才能使这个手势可
我已经在这上面花了几个小时,但无法让它工作。希望有人能帮助我。 我有一个 UIPageViewController,当我在应用程序启动时将它添加到我的默认 View 时,它可以完美地工作。这就是我所做
我想为我的 UIToolbar 使用我自己的背景。 要使用 UINavigationBar 做到这一点,我刚刚使用了这个类别并覆盖了 drawRect 方法: @implementation
我正在展示一个 UINavigationController模态地,从 iOS 应用程序扩展中: UINavigationController *nav = [[UINavigationControl
我读到在 iOS 应用程序中有这样的结构是不好的。但是,如果应用程序有很多 UINavigationController 和 UITabBarController 怎么办?但是一个UINavigati
我们在 UISplitViewController 应用程序中有我们需要的特定行为。我们有以下 3 个 View 的层次结构 FormOneViewController - 在 MasterView
我试图将一个简单的 UIToolbar 放在模态呈现的 UINavigationController 的底部。在这个示例中,它应该包含两个按钮“取消”和“某事”。 ... UINavigationCo
我有一个 UITabBarController,其中包含一些选项卡。其中一个选项卡具有 UINavigationController 和 UITableViewController 作为 Root V
我的应用程序的整个导航系统都是围绕导航 Controller 构建的。我所有的风险投资公司都被插入和推出。我有一个从左侧出来的菜单系统“抽屉”,它是我的自定义导航 Controller 的一部分。在菜
我有一个 UINavagationController (NC),它显示“Items”数组的多个 UIViewController (VC) View ,并且我有一个 UINavigationCont
在我的 UISplitViewController ,主 View 是UINavigationController包含 UITableViewController .有时,当用户选择表中的项目时,我不
我是一名优秀的程序员,十分优秀!