-
键盘退出的方法查看全部
-
常用控件查看全部
-
字符转图片 image.image=UIImage(named:string(imageNumber))查看全部
-
var controller:SLComposeViewController=SLComposeViewController(forServiceType: SLServiceTypeSinaWeibo) controller.setInitialText("alioo的处女座哟,欢迎捧场") controller.addImage(myimg.image) self.presentViewController(controller,animated:true,completion: nil)查看全部
-
self.presentationController查看全部
-
退出键盘查看全部
-
@IBAction func submit(sender: AnyObject) { var gg = "" let n = name.text! if gender.selectedSegmentIndex == 0 { gg = "gc" } else if gender.selectedSegmentIndex == 1 { gg = "bd" } else { gg = "qt" } let gregorian = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) let now = NSDate() let components = gregorian?.components(NSCalendarUnit.Year, fromDate: data.date, toDate: now, options: NSCalendarOptions(rawValue: 0)) let age = components!.year let p = hasProperty.on ? "yes" : "no" resultLabel.text = "U name is \(n), Gender is \(gg), hasProperty \(p), height = \(heightNum.text!),age = \(age)" } @IBAction func hHasChanged(sender: AnyObject) { let slider = sender as! UISlider let i = Int(slider.value) heightNum.text = "\(i) cm" }查看全部
-
多创建了一个label 可检测输值内容, 并进行相应提示 代码感觉十分累赘. 有优化空间 @IBAction func start(sender: AnyObject) { statusLabel.text = "" if let year = Int (inputOfYears.text!) { if year <= 4 { statusLabel.text = "\(year)?年龄太小?" } else { let imageNumber = (year - 4) % 12 picOfYears.image = UIImage(named: String(imageNumber)) statusLabel.text = "" } } else if inputOfYears.text?.characters.count < 1 { statusLabel.text = "没输值啊大哥" } else { if let info = inputOfYears.text { statusLabel.text = "\(info)?什么鬼?" } else { // Nothing } } }查看全部
-
Int(StringValue), 即 let year = Int(yearOfbirth.text!)查看全部
-
uuid:唯一标识查看全部
-
let url = NSURL(string: image.url) let data = NSData(contentsOfURL: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check imageURL.image = UIImage(data: data!)查看全部
-
var title = cell.viewWithTag(101) as UILabel var image = cell.viewWithTag(102) as UIImageView let locale = NSLocale.currentLocale() dateFormatFromTemplate stringFromDate查看全部
-
date类型格式化查看全部
-
使用三目运算符时,如果冒号打成中文符号,会报错为 …… ':'查看全部
-
为了防止在显示170厘米等的身高数据时,因为阿拉伯数字大小的差距,而导致无法完全显示,从而出现,末尾显示为...的现象,应该设置label的格式为右对齐,并且,在左方留出一段较长的区域查看全部
举报
0/150
提交
取消