- 浏览: 518021 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
tangyunliang:
大哥你太历害了谢谢
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
u013015029:
LZ,请问下,在// 添加消息到聊天窗口 , 这里获取Ed ...
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
endual:
怎么保持会话,我搞不懂啊
Android基于XMPP Smack Openfire开发IM【一】登录openfire服务器 -
donala_zq:
显示:[2013-11-30 11:50:36 - Andro ...
android-----------新浪微博 -
donala_zq:
哥,运行不了啊
android-----------新浪微博
这是iPhone开发多视图技术系列最后一篇,说说使用SegmentedControl实现视图切换。
实现的功能:通过UISegmentedControl模拟多视图切换。
关键词:多视图UISegmentedControl
UISegmentedControl是一个横向的组件,由多部分组成,每一部分都是一个独立的按钮,一般用来切换视图的显示模式或者在几项之间做单选。
这个控件并不是用来实现多视图切换的,实际开发中也几乎不用它来做多视图切换,此博文仅为模拟多视图应用。
1、创建一个Empty Application工程,命名为:MultiView-Navigation,如下图
[img]
[/img]
2、选中工程中的Group MultiView-Tab,然后按住CMD(Windows键)+N,新建视图控制器MainViewController,如下图
[img]
[/img]
3、依照上步,新建视图控制器FirstViewController、SecondViewController
4、修改MainViewController.xib,添加一个ToolBar控件,一个Segmented Control 控件,两个Fixed Space Bar Button Item控件,如下:
[img]
[/img]
5、修改FirstViewController.xib、SecondViewController.xib,各添加一个Label控件,如下:
[img]
[/img] [img]
[/img]
6、修改AppDelegae类,AppDelegate.h如下:
AppDelegate.m主要修改didFinishLaunchingWithOptions方法,如下:
7、下面开始编写代码,主要修改MainViewController类,MainViewController.h如下:
MainViewController.m如下:
注意,不要忘记设置输出口和操作与xib文件中控件与事件的连接,如下:
[img]
[/img]
8、编译、运行,效果如下:
[img]
[/img] [img]
[/img]
实现的功能:通过UISegmentedControl模拟多视图切换。
关键词:多视图UISegmentedControl
UISegmentedControl是一个横向的组件,由多部分组成,每一部分都是一个独立的按钮,一般用来切换视图的显示模式或者在几项之间做单选。
这个控件并不是用来实现多视图切换的,实际开发中也几乎不用它来做多视图切换,此博文仅为模拟多视图应用。
1、创建一个Empty Application工程,命名为:MultiView-Navigation,如下图
[img]
[/img]
2、选中工程中的Group MultiView-Tab,然后按住CMD(Windows键)+N,新建视图控制器MainViewController,如下图
[img]
[/img]
3、依照上步,新建视图控制器FirstViewController、SecondViewController
4、修改MainViewController.xib,添加一个ToolBar控件,一个Segmented Control 控件,两个Fixed Space Bar Button Item控件,如下:
[img]
[/img]
5、修改FirstViewController.xib、SecondViewController.xib,各添加一个Label控件,如下:
[img]
[/img] [img]
[/img]
6、修改AppDelegae类,AppDelegate.h如下:
#import <UIKit/UIKit.h> #import "MainViewController.h" @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) MainViewController *mainViewController; @end
AppDelegate.m主要修改didFinishLaunchingWithOptions方法,如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.mainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil]; //设置根视图控制器 self.window.rootViewController = self.mainViewController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
7、下面开始编写代码,主要修改MainViewController类,MainViewController.h如下:
#import <UIKit/UIKit.h> #import "FirstViewController.h" #import "SecondViewController.h" @interface MainViewController : UIViewController{ } @property(strong,nonatomic)FirstViewController *firstViewController; @property(strong,nonatomic)SecondViewController *secondViewController; @property(strong,nonatomic)IBOutlet UISegmentedControl *segmentControl; @property(strong,nonatomic)IBOutlet UIToolbar *toolBar; -(IBAction)changeView:(id)sender; @end
MainViewController.m如下:
#import "AppDelegate.h" @implementation AppDelegate @synthesize window = _window; @synthesize mainViewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.mainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil]; //设置根视图控制器 self.window.rootViewController = self.mainViewController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end
注意,不要忘记设置输出口和操作与xib文件中控件与事件的连接,如下:
[img]
[/img]
8、编译、运行,效果如下:
[img]
[/img] [img]
[/img]
- MultiView-SegmentControl.zip (35.9 KB)
- 下载次数: 2
发表评论
-
新风作浪博客学习(十九)在iOS虚拟键盘上添加动态隐藏按钮
2013-06-08 09:19 823为了给用户比较良好的交付,想在键盘上添加一个按钮,实时根据键盘 ... -
新风作浪博客学习(十八)openURL的使用(iOS调用系统电话、浏览器、地图、邮件等) .
2013-06-08 09:19 936今天遇见一行代码实现打开一个网页,比起印象里的UIWebVie ... -
新风作浪博客学习(十七)UIImageView响应点击事件 .
2013-06-08 09:19 670有时候会遇到点击一张图片,然后让这张图片触发一个事件,或者是跳 ... -
新风作浪博客学习(十六)Navigation + Tab Bar 常用组合框架 .
2013-06-07 08:50 1194看到很多项目中都采用的是Navigation加Tab Bar组 ... -
新风作浪博客学习(十五)google地图定位小Demo .
2013-06-07 08:50 1062[img][/img]今天写的是一个简单功能的google地图 ... -
新风作浪博客学习(十四)怎样向iPhone模拟器中添加图片 .
2013-06-07 08:50 745在我们做项目中可能需要使用图库,模拟器是有图库的,但是如何像其 ... -
新风作浪博客学习(十三)表视图的分组分区和索引分区 .
2013-06-07 08:50 749本次实现的是表视图的分区和索引,代码和前面都差不多,主要还是代 ... -
新风作浪博客学习(十二)代码实现UITableViewCell表视图单元定制 .
2013-06-07 08:49 934通常情况下我们会希望单元格UITableViewCell显示自 ... -
新风作浪博客学习(十一)UITableViewCell的标记、移动、删除、插入 .
2013-06-06 09:15 1064这篇文章是建立在 代码实现 UITableView与UITa ... -
新风作浪博客学习(十)代码实现 UITableView与UITableViewCell .
2013-06-06 09:14 1116我们常用的表格类视图就是用 UITableView与UITab ... -
新风作浪博客学习(九)两个UIPickerView控件间的数据依赖 .
2013-06-06 09:14 1042本篇实现功能是两个选取器的关联操作,滚动第一个滚轮第二个滚 ... -
新风作浪博客学习(八)代码实现UIPickerView .
2013-06-06 09:14 1247先说一下当个组件选取器,我们创建一个数组NSAray来保存选取 ... -
新风作浪博客学习(七)代码 实现UIDatePicker控件 和 Tab Bar 视图切换 .
2013-06-06 09:15 1078感觉代码写控件都一个理,先在ViewDidLoad中创建控件对 ... -
新风作浪博客学习(六)ios 视图切换翻页效果 .
2013-06-05 11:18 1028本文写的是视图切换,涉及到的内容有 1.实现代码添加Navi ... -
新风作浪博客学习(五)代码实现UISlider 和 UISwitch .
2013-02-18 09:15 1077本次实现的UISlider和UISwi ... -
新风作浪博客学习(四)把plist里数据显示在textField上 .
2013-02-18 09:15 887在代码实现Lable 、textFie ... -
新风作浪博客学习(三)NSBundle读取图片 plist文件和txt文件
2013-02-18 09:15 1640本文想简单介绍一下NSBundle读取图片到视图上,读取pli ... -
新风作浪博客学习(二)代码实现Lable 、textField创建界面以及键盘的处理
2013-02-18 09:15 1140今天写的是用代码实现一个简单界面,代码重复率比较高,可读性不是 ... -
新风作浪博客学习(一)plist文件读写操作
2013-02-18 09:14 1310文件plist 全名Property List,属性列表文件, ... -
GCDiscreetNotificationView提示视图
2013-06-05 11:17 531先看一下效果图: [img] ...
相关推荐
博文http://blog.csdn.net/m_changgong/article/details/8213431源代码
android-segmented-control.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
可以自定义,实现了block,delegate回调 自定义属性有: @property (nonatomic , strong) NSArray *btnTitleArray; @property (nonatomic , strong) UIColor *btnTitleNormalColor; @property (nonatomic , ...
Segmented Buttons ,Segmented Buttons 是一个 iOS 控件,添加了类似 Tweet 风格的 iOS S...
android-segmented-control库的Eclipse 版本 http://jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0512/1615.html
物料分段控制 ...import 'package:material_segmented_control/material_segmented_control.dart' ; 基本用法 int _currentSelection = 0 ; MaterialSegmentedControl ( children : _children, sel
android-segmented-control-view.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
继承RadioGroup实现的功能菜单 参考github。压缩包中有截图
分段的一个简单的 Android UI 库,用于具有材质风格的分段控件。如何添加? I. 在您的根build.gradle文件中添加以下... com .creageek.segmentedbutton.SegmentedButton android : id = " @+id/segmented "
An Android library that bring segmented control style to TabLayout. Target platforms API level 14 or later Latest version Version 1.1.0 (JUL. 12, 2016) Usage In order to use the library, there ...
yarn add rn-segmented-control # or npm i rn-segmented-control :clockwise_vertical_arrows: 依存关系 npm i prop-types :magnifying_glass_tilted_left: 用法 import React from "react" ; import { ...
Segmented Radio Buttons介绍: 在Android中实现类似iOS的分段单选按钮(segmented control)。 测试环境: Eclipse 4.2, Android 3.0 以上。 注意:测试环境并不代表适用环境。
#Segmented和Validated输入## Description这个JQueryUI小部件接受单个文本输入,并将其分成输入段,每个输入段可以定义单独的参数,包括验证。 ## Dependency JQuery,JQueryUI(小部件基础+自动完成) ##用法: $...
利用matlab对三维点云数据进行规则化切割,如:将一片点云数据切割为10行15列,直接用该代码跑完即可,跑完之后,在该matlab的文件夹,会出现10*15个个txt文档。
android-segmented-control Android-Segmented is a custom view for Android which is based on RadioGroup and RadioButton widget. This implementation is inspired by Segmented Controls for iOS. Including ...
打造UISwitch样式(开关样式)的segment。用户用手指划动代替点击动作来选择某一个的segment。 注意:请在Mac下解压使用
项目地址:https://github.com/klongmitre/android-segmented-control-view效果图:如何使用xml中直接创建<org.mitre.ascv.AndroidSegmentedControlView android:id="@ id/androidSegmentedControlView" ...
react-native-custom-segmented-control, IOS SegmentedControl组件的自定义版本 react-native-custom-segmented-control带自定义样式的分段控件的本机用户界面组件animationType:'middle-line' selectedLineAlign:'...
Chapter 1: Data Converter History ........................................................................................3 Section 1-1: Early History ....................................................