小编Ada*_*ung的帖子

如何在Swift中使用下标和上标

我希望我的UILabel以下列方式显示文本6.022*10 23.迅速对下标和上标有什么影响?

ios swift

37
推荐指数
5
解决办法
2万
查看次数

如何将int转换为nsindexpath?

我正在做一个基本的测验应用程序.选择是以表格视图的形式.如果用户移动到上一个问题,我想向他显示他之前选择的选项.我已将选择存储在NSUserDefaults中.如何将此int值转换为NSIndexpath并在我的tableview中使用它?

nsuserdefaults nsindexpath ios swift

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

带有ImageView的UIScrollView不能垂直滚动

我有一个UIImageView它的图像大于屏幕尺寸.我有这个UIImageView作为子视图UIScrollView.现在,我无法向下滚动.查看整个图像.但缩放功能正常.

@IBOutlet weak var scrollView: UIScrollView!

var imageView = UIImageView();

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

func centerScrollViewContents(){
    let boundsSize = scrollView.bounds.size
    var contentsFrame = imageView.frame

    if contentsFrame.size.width < boundsSize.width {
       contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2
    }
    else { 
       contentsFrame.origin.x = 0
    }

    if contentsFrame.size.height < boundsSize.height {            
        contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2
    }
    else {
        contentsFrame.origin.y = 0
    }

    imageView.frame = contentsFrame
   // scrollView.frame = contentsFrame        
}

func scrollViewDidZoom(scrollView: …
Run Code Online (Sandbox Code Playgroud)

uiscrollview uiimageview ios swift

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

SecurityError:无法在'History'上执行'replaceState':

我在所有浏览器中都面临着这个问题.每当我尝试在Google缓存中查看我的网站时,都会出现此问题

main.bundle.js:1 ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://mydomainn.com/' cannot be created in a document with origin 'http://webcache.googleusercontent.com'.快递谷歌也存在同样的问题.http://webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Fexpress.google.com%2Fstores&oq=cache%3Ahttps%3A%2F%2Fexpress.google.com%2Fstores&aqs=chrome..69i57j69i58 .3999j0j4&sourceid = chrome&ie = UTF-8.

我的基础href是 /

universal server-side-rendering ssr angular

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

以编程方式在swift中加载图像

我有一个ImageView.这是我用来将图像添加到ImageView的代码

 var imgstr = pf["ImageFileName"] as String
 image = UIImage(named: imgstr)!
 println(imgstr) //the output here is abc.png
 self.Imageview.image = image
Run Code Online (Sandbox Code Playgroud)

现在我在我的Project文件夹中有图像,如截图所示截图

我仍然在运行时收到此错误

致命错误:在展开Optional值时意外发现nil

ios swift

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

自我调整细胞不适用于Swift

我没有添加任何原型单元格,但它应该根据最新的iOS 8 tableView工作.这是我的代码

class ViewController: UIViewController,UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
var tabledata = ["hn, helooo dnsjakdnksandksajndksandkasjnkc sacjkasc jkas kjdjknasjkdnsaklmdlksamxklsamxlksamdklsandk cnsdjdnsklnjnfkdnflasfnlfnkdsnfjkdnfjkdsnjkd njsdkadnaksjdnjkasndsakdnkasdnsalkdn cjkndskasdnsakndksandjksandksajndkj ndsjkadnksalndls;adnklsa;mdas,mcjksanckasdjnklscaskncjks" , "hi i am ishan, helooo dnsjakdnksandksajndksandkasjnkc sacjkasc jkas kjdjknasjkdnsaklmdlksamxklsamxlksamdklsandk cnsdjdnsklnjnfkdnflasfnlfnkdsnfjkdnfjkdsnjkd njsdkadnaksjdnjkasndsakdnkasdnsalkdn cjkndskasdnsakndksandjksandksajndkj ndsjkadnksalndls;adnklsa;mdas,mcjksanckasdjnklscaskncjkssndjkasndjksandkjasndkjasndkjasndkjasndjka ", "a" ]
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return tabledata.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
   let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")

    cell.textLabel.text …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

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

在Swift中禁用没有UserInteractionEnabled的单元格选择

我有一个带按钮的单元格,设置UserInteractionEnabled为false也会禁用该按钮.现在,如果我使用cell.selectionStyle = UITableViewCellSelectionStyle.None.虽然单元格没有突出显示,但我松开了之前选择的单元格.有什么方法可以解决这个问

ios swift

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

检查用户在网站上使用的平台

我有一个网站.如果他来到我的网站,我想知道他正在使用哪个用户.例如.iOS,Android,Windows手机,Windows PC.特别是对于iOS,我想检查他是在iPhone还是现在

javascript web

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