We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var url = NSURL(string: "http://www.stackoverflow.com") var request = NSURLRequest(URL: url) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler: {(response: NSURLResponse!, data: NSData!, error: NSError!) in println(NSString(data: data, encoding: NSUTF8StringEncoding)) })
let alertView:UIAlertView = UIAlertView() alertView.title="提示" alertView.message="恭喜你,你中奖了!" alertView.addButtonWithTitle("确定") alertView.show()
或者
var alert:UIAlertController = UIAlertController(title: "提示", message: "恭喜你,你中奖了!", preferredStyle: UIAlertControllerStyle.Alert) var action: UIAlertAction = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default, handler: { ac -> Void in }) alert.addAction(action) self.presentViewController(alert, animated: true, completion: nil)
//设置导航栏按钮(左边) let leftBarButtonItem:UIBarButtonItem = UIBarButtonItem(title: "主页", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("showMain")) self.navigationItem.leftBarButtonItem = leftBarButtonItem //设置导航栏按钮(右边) let rightBarButtonItem:UIBarButtonItem = UIBarButtonItem(title: "设置", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("showSetting")) self.navigationItem.rightBarButtonItem = rightBarButtonItem //设置导航栏名称 self.navigationItem.title="全国主要城市PM2.5" func showMain(){ //SCLAlertView().showTitle(self, title: "提示", subTitle: "你点击了主页", duration: 2.0, style: SCLAlertViewStyle.Info) var alert = UIAlertController(title: "提示", message: "你点击了主页", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in println("你点击了确定按钮") })) self.presentViewController(alert, animated: true, completion: nil) } func showSetting(){ //SCLAlertView().showTitle(self, title: "提示", subTitle: "你点击了设置", duration: 2.0, style: SCLAlertViewStyle.Info) var alert = UIAlertController(title: "提示", message: "你点击了设置", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in println("你点击了确定按钮") })) self.presentViewController(alert, animated: true, completion: nil) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Swift Code 碎片整理
1. NSURLConnection
2. UIAlertView
或者
3. navigationItem
The text was updated successfully, but these errors were encountered: