小编Ork*_*ade的帖子

如何锁定一个视图控制器的方向?

我可以在一个控制器中设置纵向和锁定方向吗?

我试过了:

override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}

override func shouldAutorotate() -> Bool{
    return false
}
Run Code Online (Sandbox Code Playgroud)

但它对我没有帮助.我必须添加其他东西吗?

portrait orientation ios swift

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

点击Swift中的标签

我想制作点击它的标签来打电话给号码.我知道iOS有这个选项,但我怎么能在Swift中做到这一点?

我发现如何在ObjC中做到这一点:

-(IBAction)callPhone:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:2135554321"]];
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我吗?

iphone objective-c call ios swift

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

Swift 2语法错误与方向.Forward

我在下一篇文章中写道:

self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

但现在,在Swift 2中它打印出下一个错误:

Could not find member 'Forward'
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

syntax-error ios swift swift2

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

textView中的HTML

我想在textView中粘贴HTML文本(带有p,br,bgcolor等).我确实试过了下一个:

var bodyText = NSAttributedString(data: body.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)

postBody.text = bodyText
Run Code Online (Sandbox Code Playgroud)

postBody - > textView.但它会打印下一个错误:

Cannot assign a value of type 'NSAttributedString?' to a value of type 'String!'

如何在textView中正确打印?

swift

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

以编程方式在Swift中定位对象

我想以编程方式设置对象的位置.为此我做:

youtubeIco.frame.origin.y = 100
Run Code Online (Sandbox Code Playgroud)

但没什么.它根本不会改变坐标.问题是什么?

第二个问题:

当我设置webView的XCode约束时(例如:10(顶部,左侧,右侧,底部)它会消失.但是当我没有为它设置约束时,它会出现.问题是什么?

我想这样:

在此输入图像描述

xcode ios swift

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

标签 统计

swift ×5

ios ×4

call ×1

iphone ×1

objective-c ×1

orientation ×1

portrait ×1

swift2 ×1

syntax-error ×1

xcode ×1