这个App的是storyboard+code的结合,主要的重点是:

1.segue传递图片值。

2.Autolayout中可以使用右下角三角符号使用Add Missing Constraints进行大概约束,使之适应不同大小屏幕。

3.上边栏Editor -> Embed In -> Navigation Controller或者Tab Bar Controller。

4.实现分享功能。

5.注意storyboard设计Navigation Controller界面时关于segue的modal类型要改为push类型。

6.按住Command点击某个Controller控件代码可显示其方法类。

storyboard设计界面:

目录结构:

ViewController.swift文件代码:

 import UIKit
class ViewController: UIViewController { @IBOutlet weak var beautyPicker: UIPickerView!
let beauties = ["范冰冰","李冰冰","王菲","杨幂","周迅"]
override func viewDidLoad() {
super.viewDidLoad()
beautyPicker.dataSource = self
beautyPicker.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "GoToGallery"{
let index = beautyPicker.selectedRowInComponent(0)
var imageName:String?
switch index{
case 0:
imageName = "fanbingbing"
case 1:
imageName = "libingbing"
case 2:
imageName = "wangfei"
case 3:
imageName = "yangmi"
case 4:
imageName = "zhouxun"
default:
imageName = nil }
var vc = segue.destinationViewController as! GalleryController
vc.imageName = imageName
}
}
}

View.swift (ViewController.swift的额外扩展文件):

 import UIKit

 extension ViewController:UIPickerViewDataSource{
// returns the number of 'columns' to display.
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int{
return 1
}
// returns the # of rows in each component..
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{
return beauties.count
}
}
extension ViewController:UIPickerViewDelegate{
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String!{
return beauties[row]
}
}

GalleryController.swift文件代码:

 import UIKit
import Social

class GalleryController: UIViewController {
var imageName:String? @IBOutlet weak var beautyImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
/*if (imageName != nil){
beautyImage.image = UIImage(named: imageName!)//修改前
}*/ if let name = imageName {
beautyImage.image = UIImage(named: name)
switch name{
case "fanbingbing":
navigationItem.title = "范冰冰"
case "libingbing":
navigationItem.title = "李冰冰"
case "wangfei":
navigationItem.title = "王菲"
case "yangmi":
navigationItem.title = "杨幂"
case "zhouxun":
navigationItem.title = "周迅"
default:
navigationItem.title = "女神画廊"
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} //分享按钮
@IBAction func shareTapped(sender: AnyObject) {
var controller: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTencentWeibo)
controller.setInitialText("一起来玩女神画廊app吧,就在Github上")
controller.addImage(beautyImage.image)
self.presentViewController(controller, animated: true, completion: nil)
}
}

KoreanViewController文件代码:

 import UIKit
import Social
class KoreanViewController: UIViewController {
@IBOutlet weak var beautyImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//facebook分享
@IBAction func facebooTapped(sender: AnyObject) {
var controller: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
controller.setInitialText("一起来玩女神画廊app吧,就在Github上")
controller.addImage(beautyImage.image)
self.presentViewController(controller, animated: true, completion: nil)
}
//twitter分享
@IBAction func twitterTapped(sender: AnyObject) {
var controller: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
controller.setInitialText("一起来玩女神画廊app吧,就在Github上")
controller.addImage(beautyImage.image)
self.presentViewController(controller, animated: true, completion: nil)
}
//微博分享
@IBAction func WeiboTapped(sender: AnyObject) {
var controller: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeSinaWeibo)
controller.setInitialText("一起来玩女神画廊app吧,就在Github上")
controller.addImage(beautyImage.image)
self.presentViewController(controller, animated: true, completion: nil)
}
}

运行结果:

github地址:https://github.com/AbelSu131/BeautyGallery

女神画廊App (Swift1.2)的更多相关文章

  1. Android ViewPager打造3D画廊

    本文已授权微信公众号:鸿洋(hongyangAndroid)在微信公众号平台原创首发. 网上有很多关于使用Gallery来打造3D画廊的博客,但是在关于Gallery的官方说法中表明: This cl ...

  2. 英语学习app分析

    以下数据分析由队员张波收集整理队员链接 队友的博客 一.数据统计 为了让统计数据更加准确可信,我们选取了三款android平台的应用市场软件作为数据的来源. 英语学习app下载量统计表: 序号 应用名 ...

  3. Android -- 使用ViewPager实现画廊效果

    1,今天在微信推送文章看到实现画廊效果,感觉挺不错的,就来写写试试,先来看一下效果图: 上面的效果基本上可以用两个功能点来包含:ViewPager的切换动画.ImageView的倒影的实现 嗯,先来将 ...

  4. iOS完整App资源收集

    前言 iOS开发学习者都希望得到实战训练,但是很多资料都是只有一小部分代码,并不能形成完成的App,笔者在此处收集了很多开源的完整的App,都有源代码哦! 本篇文章持续更新中,请持续关注.本篇所收集的 ...

  5. 闹钟类app构想

    NABC--闹钟app N:我们打算针对那些易健忘的人来制作一款闹钟功能的记事本,具来说服务的对象有很多:有健忘的人,还有情侣,北漂的人及其父母(...),常年见不到亲人(双方),后期我们若提前完成基 ...

  6. Android 高仿豌豆荚 一键安装app 功能 实现

    以往我们那些应用市场 帮我们安装app的时候  我们都得点确定,当然你如果 root 以后 不用点确定 也能自动安装了,后来豌豆荚 推出了一个功能 非root的手机也能不点确定 直接帮你安装好.(如果 ...

  7. Android 高级UI设计笔记15:HorizontalScrollView之 实现画廊式图片浏览器

    1. HorizontalScrollView 本来,画廊式的图片浏览器,使用Android中的Gallery就能轻松完成,但是Google说Gallery每次切换图片时都要新建视图,造成太多的资源浪 ...

  8. Android 高级UI设计笔记11:Gallery(画廊控件)之Gallery基本使用

    1. 这里要向大家介绍Android控件Gallery(画廊控件) Gallery控件主要用于横向显示图像列表,不过按常规做法.Gallery组件只能有限地显示指定的图像.也就是说,如果为Galler ...

  9. Android画廊控件之Gallery

    Gallery:用来显示图片列表.可以左右拖动. 如图: 图片取自http://www.cnblogs.com/menlsh/archive/2013/02/26/2934434.html 在Gall ...

随机推荐

  1. 第一章 深入.NET框架

    一. .NET的过人之处 1..NET框架提高了软件的可重复行 ,可扩展性,可维护行和灵活性. 2.对web应用的强大支撑. 3.对Web Service(Web服务)的支持. 4.实现SOA,支持云 ...

  2. IDEA项目搭建五——使用JRebel插件实现IDEA热部署

    使用IDEA开发时修改了html或js或java代码都需要编译启动浪费了很多时间,所以可以借助热部署插件实现自动编码,每次修改完代码保存后就可以刷新页面看效果很方便,热部署工具有很多在此只推荐JReb ...

  3. [基础知识]row类visible使用

    使用row的visibe属性,要反向遍历rowset,因为如果正向遍历,rowset是实时变化的,行号是错误的.正确代码如下: Local integer &k; For &k = & ...

  4. 《Spring实战》-- 'cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element' 错误的解决办法

    在Eclipse中新建了一个maven项目学习Spring,在 service.xml 中配置 Spring,想要学习'面向切面的Spring',service.xml 内容如下: <beans ...

  5. Win7/8/10十个最强大通用快捷键

    Windows 操作系统功能丰富,可视化的界面能够帮助我们提高工作效率.不过,日常使用中,很多用户都习惯“一只鼠标走天下”,频繁的点击让手指疲惫不堪. 为此,我们总结了十个适用于 Windows 7 ...

  6. linux设置永久环境变量

    vi /etc/profile 文件最后输入export PATH=$PATH:/usr/abc/def/ 保存 输入source /etc/profile刷新刚刚修改过的环境变量文件

  7. 美图DPOS以太坊教程(Docker版)

    一.前言 最近,需要接触区块链项目的主链开发,在EOS.BTC.ethereum.超级账本这几种区块链技术当中,相互对比后,最终还是以go-ethereum为解决方案. 以ethereum为基准去找解 ...

  8. kafka入门1:安装及配置

    1下载 官方下载地址:https://kafka.apache.org/downloads 案例使用版本:kafka_2.11-1.1.0.tgz 2上传服务器 使用ftp工具将压缩包放置到服务器上 ...

  9. 转:C#综合揭秘——细说多线程(下)

    原文地址:http://www.cnblogs.com/leslies2/archive/2012/02/08/2320914.html 引言 本文主要从线程的基础用法,CLR线程池当中工作者线程与I ...

  10. 参观阿拉斯加进行产品培训[My representation]

    I  suggest to visit Alaska for product training. Alaska is one of the best places to spend a trainin ...