小编Dav*_*ord的帖子

UISplitView的MasterViewController和导航问题

我正在更新我现有的应用程序以包含适用于iPad的SplitView.

我使用UITabBar,但是我的masterViewController有问题,因为它生成了一个"重复"导航栏,覆盖了所有masterViewControllers(选项卡)上的现有导航项,包括搜索选项卡上的searchBar.

我的代码是:

AppDelegate中

class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{

    let splitViewController = self.window!.rootViewController as! UISplitViewController
    splitViewController.delegate = self
    splitViewController.preferredPrimaryColumnWidthFraction = 0.33
    splitViewController.minimumPrimaryColumnWidth = 375
    splitViewController.preferredDisplayMode = .allVisible

    return true
}

func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
    return true
}
Run Code Online (Sandbox Code Playgroud)

在AppDelegate中有这个的原因是我看到了一个示例,其中放置它听到将允许我不要求每个不同的主视图(每个选项卡)中的代码.还没有测试这仍然在第一个主视图上工作.

主视图

override func viewDidLoad()

{

    self.extendedLayoutIncludesOpaqueBars = true

    self.navigationItem.hidesBackButton = true

    // 3D Touch
    if traitCollection.forceTouchCapability == .available {
        registerForPreviewing(with: self as UIViewControllerPreviewingDelegate, …
Run Code Online (Sandbox Code Playgroud)

uinavigationbar uisplitviewcontroller ios swift

6
推荐指数
1
解决办法
173
查看次数

将完成按钮添加到UITableViewCell中的数字键盘

我在UITableview中使用动态单元格,并尝试创建一个完成按钮,该按钮将在UITableViewCell中显示数字键盘.

我有一个代码在ViewController中为其他字段完成此操作,但是当UITableViewCell中的字段时,这不起作用.

IBOulet在这里:

class StartingTankUsageCell: UITableViewCell, UITextFieldDelegate
{

    @IBOutlet var startingPressureTextField: UITextField!
Run Code Online (Sandbox Code Playgroud)

我在我的ViewController中设置了:

import UIKit

class DiveDetailsViewController: UITableViewController, LocationDelegate, ItemDataSelectedProtocol
{

override func viewDidLoad()
{
    super.viewDidLoad()
    self.addDoneButtonOnKeyboardStartingPressure()
}

// DONE button on NumberPad for StartingPressure
func addDoneButtonOnKeyboardStartingPressure()
{
    let doneToolbar: UIToolbar = UIToolbar(frame: CGRectMake(0, 0, 320, 50))
    doneToolbar.barStyle = UIBarStyle.Default

    let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
    let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Done, target: self, action: #selector(DiveDetailsViewController.addDoneButtonOnKeyboardStartingPressure))

    var items = [UIBarButtonItem]()
    items.append(flexSpace)
    items.append(done)

    doneToolbar.items …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

2
推荐指数
1
解决办法
590
查看次数

如何在 Swift 中替换多元素 NSArray 的单个变量

我正在努力更新结构创建的数组中的单个变量。

struct CurrentPolicyItems {
    var id:Int
    var currentInsured:String
    var currentPremium:String
    var currentXDate:String
    var typeID:Int
    var productID:Int
    var buildingID:Int
    var noteID:Int
    var isUsed:Int
    var isTemp:Int
}
struct CurrentPolicyTemp {
    static var array = [CurrentPolicyItems]()
}
Run Code Online (Sandbox Code Playgroud)

当我关闭一个类时,我需要将所有 var“isTemp”从 1 更改为 0。并非所有元素都被使用,因此我需要在任何更新之前过滤它们。我相信我已经很接近了,只是无法得到最后一点。

我努力了:

    if let items = CurrentPolicyTemp.array.firstIndex( where: { $0.isTemp == 1}) {
    CurrentPolicyTemp.array[items].isTemp = 0
    }
Run Code Online (Sandbox Code Playgroud)

然而,众所周知,这只会更新单个元素。我尝试过 .filter,但遇到了“item is immutable”错误。

请帮助。

arrays nsarray ios swift

0
推荐指数
1
解决办法
266
查看次数