小编sim*_*sd3的帖子

比较2个数组并列出差异 - Swift

我想知道如何比较2个布尔数组并列出不匹配的布尔值.

我写了一个2个数组的简单例子.

let array1 = [true, false, true, false]
let array2 = [true, true, true, true]
Run Code Online (Sandbox Code Playgroud)

我如何比较array1和array2并显示不匹配.我试图这样做来检查测验游戏的用户结果.

谢谢!

arrays boolean compare swift

11
推荐指数
3
解决办法
1万
查看次数

如何使这个segue动画退出到右侧或左侧? - 斯威夫特

此代码可以正常使用向下动画进行自定义segue过渡.如何使动画看起来像是向左或向右转换?

另外 - 我正在使用UISwipeGestureRecognizer来触发segue.它工作正常,除了我做最小的滑动时发生segue.如果用户已将手指抬起或至少进行了较大的滑动,我将如何允许不发生segue.我需要使用scrollView吗?

下面是我的UISwipeGestureRecognizer的代码.

override func viewDidLoad() {

    var swipeGestureRecognizer: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "showSecondViewController")
    swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirection.Up
    self.view.addGestureRecognizer(swipeGestureRecognizer)

}    
Run Code Online (Sandbox Code Playgroud)

下面的代码是我的动画代码

class FirstCustomSegue: UIStoryboardSegue {

override func perform() {

    // Specify the initial position of the destination view.
    secondVCView.frame = CGRectMake(0.0, screenHeight, screenWidth, screenHeight)

    // Access the app's key window and insert the destination view above the current (source) one.
    let window = UIApplication.sharedApplication().keyWindow
    window?.insertSubview(secondVCView, aboveSubview: firstVCView)

    // Animate the transition.
    UIView.animateWithDuration(0.5, animations: { () -> Void in …
Run Code Online (Sandbox Code Playgroud)

swipe ios segue swift

3
推荐指数
1
解决办法
1705
查看次数

如何向Custom UITableViewCell添加约束

我已经为我的表视图创建了一个自定义单元格,它工作正常,只是我的图像视图不能正确对齐.

有没有办法向自定义单元格视图添加约束?以编程方式或其他方式

这就是我的单元格在故事板中的样子 - 这是我希望在运行时实现的:

但是,当我演示应用程序时,会发生以下情况:

这是故事板中的另一张图片:

查看Controller/w TableView

@IBOutlet weak var tableView: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()


    println(questions)
    println(finalResults)

    let theWidth = view.frame.size.width
    let theHeight = view.frame.size.height

    tableView.frame = CGRectMake(0,0, theHeight, theWidth)
}
Run Code Online (Sandbox Code Playgroud)

单元视图控制器

override func awakeFromNib() {

    let theWidth = UIScreen.mainScreen().bounds.width
    contentView.frame = CGRectMake(0,0, theWidth, 64)

    answerImage.center = CGPointMake(115, 15)
}
Run Code Online (Sandbox Code Playgroud)

constraints cell tableview swift

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

从Xib文件到单独的View Controller的IBAction

我正在创建测验应用程序,当您向右或向左滚动时,它会更改问题-

我的自定义滚动视图有一个xib文件,该文件链接到UIView ViewController。

但是,我还有另一个ViewController可以创建scrollView。如何从XIB中获取一个动作以连接到ViewController 2。

我希望QuizViewController能够从XIB文件中获取@IBActions,以便在用户按下按钮时可以运行诸如此类的命令(显然忽略变量):

@IBAction func answerPressed(sender: UIButton) {

    if allAnswersCompleted == true {
        answerChosen = 1
        answerSelected = sender.currentTitle
        println(answerSelected!)
        lockInButton.setTitle("Lock In", forState: UIControlState.Normal)
    } else {
        answerChosen = 1
        answerSelected = sender.currentTitle
        println(answerSelected!)

    }
}
Run Code Online (Sandbox Code Playgroud)

这有可能还是我需要使用另一种方法-类似于NScoder?

View Controller 1-连接到此的xib文件

class QuestionView: UIView {


@IBOutlet weak var view: UIView!
@IBOutlet weak var falseButton: UIButton!
@IBOutlet weak var trueButton: UIButton!
@IBOutlet weak var questionText: UITextView!
@IBOutlet weak var lockInButton: UIButton!

}
Run Code Online (Sandbox Code Playgroud)

视图控制器2

class QuizViewController: UIViewController {

@IBOutlet weak …
Run Code Online (Sandbox Code Playgroud)

action xib swift

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

标签 统计

swift ×4

action ×1

arrays ×1

boolean ×1

cell ×1

compare ×1

constraints ×1

ios ×1

segue ×1

swipe ×1

tableview ×1

xib ×1