请教ios uitabbar 高度Controller 调整ios uitabbar 高度的位置

基于Storyboard的 UITabbarController与UINavgationControlle
一、新建一个空的Application二、新建storyboard将新建的MainStoryboard 设置为主storyboard三、1、拖拽UITabbarController到mainstor
一、&&&&&新建一个空的Application
二、新建storyboard
将新建的MainStoryboard 设置为主storyboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
UIStoryboard
*storyboard=[UIStoryboard storyboardWithName:@&MainStoryBoard& bundle:nil];
self.window.rootViewController=[storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
return YES;
1、拖拽UITabbarController到mainstoryboard
拖拽UITabbarController 到storyboard之后会默认生成两个UIViewController,我们这里不需要,将两个默认的ViewController删除
2、拖拽UINavgationController到storyboard& (默认会自带一个UITableviewController作为rootViewController,如果rootview不是tableview可以删除后自定义viewcontroller,这里的rootview是以UIViewcontroller为例,故删除)
3、现在storyboard 上只剩下一个UITabbarController和一个UINavgationController。按住ctrl ,从UITabbarController连线至UINavgationController& ,松开鼠标将会出现选择对话框,选择ViewController
4、连线成功后UITabbarcontroller上新增一个item
5、拖拽UIViewController 至storyboard,并与UINavgationController连线,设置为rootview;
6、重复2、3、4、5生成多个UINavgationController并关联root view
(责任编辑:赵红霞)
------分隔线----------------------------
现在一搜手机号正则和车牌号正则,都是以前写的现在手机号更...
有关延迟块儿清除、快照过旧、读一致的总结,希望把这三个知...
1安装Nodejs下载nodejs安装包(http://nodejs.org/download/)安装。 测试...
我是一个毕业10年的人,我大学学的是机电一体化,后来从事了...
leetcode上新的题目,Find Peak Element ,难度:Medium。分治法。题目...
最近发现一个很简单的,适合初学者的PHP开发环境,整个环境只...温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
观乎其上,得乎其中,
观乎其中,得乎其下。
LOFTER精选
[cpp]&2.创建每个tab对应的viewController和以该viewController为根视图控制器的UINavigationC 将naviController添加到数组中; 定制每个UITabBarItem,可以设置图片、文字、标记等;如下:tab1和tab3的创建类似
[cpp]&3. 将viewController数组设置给tabBarController,tabBarController添加到窗口显示。[cpp]&完成,显示效果如下。4. UITabBarController和naviController不是一定绑定在一起用的。[cpp]& 从上面这句话就可以看出来,我理解这句才是将tab和viewController连接起来的关键,但是每个UIViewController本身都会自动创建一个tabBarItem,因此secondController.tabBarItem = secondTab也是可以的,这就可以实现只有UITabBarController,而没有naviController。如下图所示UITabBarController.h中的相关定义,可以验证这种用法。[cpp]&二、UITabBar和UITabBarItem的一些设置。&&设置UITabBar的背景,网上流传最多的方法是取出UITabBar之后,对其layer层的contents属性进行修改,将其设置为自定义的一张背景图片,如下面注视掉的代码。不过看了头文件之后我觉得这种方法好像挺奇怪的,虽然也没几句代码,不过感觉不用这么复杂吧??取出UITabBar之后直接设置backgroundImage不就行了么?或许有潜在问题我不知道吧,先了解有这种方法吧,以备不时之需。[cpp]&UITabBarItem有两种初始化方式,本代码中使用的是设置系统tab类型,另一种更常用的应该是定制tab标题和图片,如上注释掉的语句。[cpp]&可以通过下面的函数设置选中、未选中的图片; 字符串badgeValue是可以在tab右上角的红色小圆圈内的文字内容[cpp]&这几个控件的属性不多,还有可以UITabBar选中的图片、颜色等等,通过头文件注释看到的,没有实际使用,大概使用方法都差不多。三、自定义UITabBar实际工作中,还是用纯粹的自定义TabBar的情况更多,在此先写写思路,整理好代码再来记录。第一种思路,也是我现在使用的,自定义TabBar继承UIView,每个tab是一个button,从而可以设置选中/未选中的图片,将button都添加到TabBar里面,button的点击事件就可以作为tab是否被选中的触发事件,通过delegate通知外面到底选中了哪个tab。第二种思路,既然UITabBar本身就是UIView的子类,应该可以重写drawRect函数完全自绘吧,这也是一种思路,好像一些开源代码也是这样做的。还有一些情况,可能使用UIToolBar来代替TabBar更合适,toolBar可以设置自定义的view,那就好办了,估计搞个UIActivityIndicatorView之类的设置上去都行,下一步要看看这块的文档和代码,尝试一下,写了demo再来记录。总之,ios开发中,要实现一种UI效果,可以采用的方法很多,有时候也不知道到底选择哪种方式更好了,还是按照习惯和方便性来进行吧。原帖:
阅读(3231)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'UITabBarController的使用总结',
blogAbstract:'做了这么长时间的ios开发了,最基本的UITabBarController和UINavigationController都用了好长时间了,总是改现成的代码,或者各种自定义控件的修改,用的都有些混乱了,呵呵。还是自己做个demo再复习一下吧,记录下来以备后续翻查。一、UITabBarController和UINavigationController的联合使用。',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:0,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'观乎其上,得乎其中,\r\n观乎其中,得乎其下。',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}OC类跟对象之三_UIViewController、UINavigationController与UITabBarController的调整使用_危机公关中的珍珑棋局:天猫的内裤、星巴克的暴利与大略8点20发__脚本百事通
稍等,加载中……
^_^请注意,有可能下面的2篇文章才是您想要的内容:
OC类跟对象之三
UIViewController、UINavigationController与UITabBarController的调整使用
危机公关中的珍珑棋局:天猫的内裤、星巴克的暴利与大略8点20发
OC类跟对象之三
OC类和对象之三OC类和对象之三
1,objc_getClass
根据传入的class的name获取对应的Class结构,主要使用了look_up_class方法,它从一个hash结构中根据名字获取对应的Class结构,如果没有找到则返回NULL。
使用的主要方法有: look_up_class, NXHashGet
1.2,库代码
只需要关注objc_getclass, look_up_class, NSHashGet三个方法即可。
id objc_getClass(const char *aClassName)
if (!aClassName) return N
// NO unconnected, YES class handler
return look_up_class(aClassName,NO, YES);
//根据类的名字查找对应class. old_class与Class结构体基本一致。
PRIVATE_EXTERN id look_up_class(const char *aClassName, BOOL includeUnconnected, BOOL includeClassHandler)
id result =
struct old_
query.name = aClassN
if (!result &&
class_hash) {
// Check ordinary classes
mutex_lock (&classLock);
//通过NXHashGet方法获取对应的query
result = (id)NXHashGet(class_hash,&query);
mutex_unlock (&classLock);
2,objc_addClass
将用户创建的class加入到系统的Hash结构中,加入的Class结构以后就可以使用objc_getClass获得到。虽然此方法已经被弃用了,但它描述了常规的加入Class的流程,因此简单说一下。重要方法有NXHashInsert, objc_addRegisteredClass是为了GC垃圾回收的,暂时不用考虑。
可以使用callingobjc_allocateClassPair创建一个Class. 然后通过
class_addMethodand
class_addIvar.设置此Class的属性,通过调用objc_registerClassPair将Class加入到系统中,但是由于他们使用的结构体是新的class_t的结构,不是老的old_class的结构,而我在OC类和对象之一中是使用的old_class的结构,因此这里就采用old_class结构进行讲解了。新的和老的结构变化很大,主要的区别是class_t采用C++的一些方法,已经不是单纯的结构体,而是一个类;old_class还是一个纯粹的C结构体。
2.2,新旧结构描述
struct old_class {
struct old_class *
struct old_class *super_
const char *
long instance_
struct old_ivar_list*
struct old_method_list**methodL
structold_protocol_list *
// CLS_EXT only
const uint8_t *ivar_
struct old_class_ext*
虽然是类,但是是纯粹结构体描述
typedef struct class_t {
struct class_t *
struct class_t *
uintptr_tdata_NEVER_USE;
// class_rw_t * plus flags
class_rw_t *data() const {
#if CLASS_FAST_FLAGS_VIA_RW_DATA
return (class_rw_t*)(data_NEVER_USE & ~3UL);
return (class_rw_t *)data_NEVER_USE;
void setData(class_rw_t *newData) {
#if CLASS_FAST_FLAGS_VIA_RW_DATA
uintptr_tflags = (uintptr_t)data_NEVER_USE & 3UL;
data_NEVER_USE = (uintptr_t)newData |
data_NEVER_USE = (uintptr_t)newD
bool hasCustomRR() const {
#if CLASS_FAST_FLAGS_VIA_RW_DATA
return data_NEVER_USE& 1UL;
return (data()-&flags & RW_HAS_CUSTOM_RR);
voidsetHasCustomRR();
voidunsetHasCustomRR();
boolhasIvarReleaser() const {
return (data()-&flags & RW_HAS_IVAR_RELEASER);
voidsetHasIvarReleaser();
bool isRootClass() const {
return superclass == NULL;
boolisRootMetaclass() const {
return isa ==
} class_t;
有不少C++的函数,是纯粹的类。
2.3,库代码
/***********************************************************************
* objc_addClass.
Add the specified class to the table of knownclasses,
* after doing a little verification and fixup.
**********************************************************************/
objc_addClass
(Class cls_gen)
struct old_class *cls =oldcls(cls_gen);
OBJC_WARN_DEPRECATED;
// Synchronize access to hash table
mutex_lock (&classLock);
// Make sure both the class and themetaclass have caches!
// Clear all bits of the info fields exceptCLS_CLASS and CLS_META.
// Normally these bits are already clearbut if someone tries to cons
// up their own class on the fly they mightneed to be cleared.
if (cls-&cache == NULL) {
cls-&cache = (Cache)&_objc_empty_
cls-&info = CLS_CLASS;
if (cls-&isa-&cache == NULL) {
cls-&isa-&cache = (Cache)&_objc_empty_
cls-&isa-&info = CLS_META;
// methodLists should be:
// 1. NULL (Tiger and later only)
// 2. A -1 terminated method list array
// In either case, CLS_NO_METHOD_ARRAYremains clear.
// If the user manipulates the method listdirectly,
// they must use the magic private format.
// 就关注这一句,将cls加入到hash表中
(void) NXHashInsert (class_hash,cls);
objc_addRegisteredClass((Class)cls);
// Superclass is no longer a leaf for cacheflushing
if (cls-&super_class &&(cls-&super_class-&info & CLS_LEAF)) {
_class_clearInfo((Class)cls-&super_class, CLS_LEAF);
_class_clearInfo((Class)cls-&super_class-&isa,CLS_LEAF);
// Desynchronize
mutex_unlock (&classLock);
这里面的class的get和add主要就是一个hash的插入和获取,因此我就着重翻了一下hash结构的代码,内容还不少,不过由于大学的时候学过hash,就在这里抛砖引玉一下,希望大家给出更多的分析代码。具体内容且听下回分解hash。
UIViewController、UINavigationController与UITabBarController的调整使用
UIViewController、UINavigationController与UITabBarController的整合使用
@interface UITabBarController : UIViewController &UITabBarDelegate, NSCoding&
@interface UINavigationController : UIViewController
//把UIViewController添加的应用中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
SplashViewController *splashViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
self.window.rootViewController = splashViewC
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
//从UIViewController跳转到另一个UIViewController
LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
[self presentViewController:loginViewController animated:true completion:^{}];
//从UIViewController返回上一个UIViewController
[self dismissViewControllerAnimated:true completion:^{}];
//从UIViewController跳转到UINavigationController
HomeViewController *homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
[self presentViewController:navigationController animated:true completion:^{}];
//HomeViewController是一个UITabBarController子类
@interface HomeViewController : UITabBarController&UITabBarControllerDelegate, HomeDelegate&
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
//设置导航标题
self.title = @"Message";
//设置导航左上角的按钮
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(onLeftBtnClick:)];
self.navigationItem.leftBarButtonItem = leftB
//设置导航右上角的按钮
UIImage *img = [UIImage imageNamed:@"msgIcon"];
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithImage:img style:UIBarButtonItemStyleBordered target:self action:nil];
self.navigationItem.rightBarButtonItem = rightB
//新建Tab页面
UserListViewController *userListViewController = [[UserListViewController alloc] initWithNibName:@"UserListViewController" bundle:nil];
MessageListViewController *messageListViewController = [[MessageListViewController alloc] initWithNibName:@"MessageListViewController" bundle:nil];
//添加Tab耍耍到Tab控制器
self.viewControllers = @[messageListViewController, userListViewController];
//设置UITabBarControllerDelegate代理
self.delegate =
//实现协议方法,用于切换Tab时,更改页面的标题
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSInteger index = tabBarController.selectedI
NSString *
switch (index) {
title = @"Message";
title = @"User List";
self.title =
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.tabBarItem.title = @"User List";
self.tabBarItem.image = [UIImage imageNamed:@"chatIcon01"];
//从UITabBarController的子页面跳转到UINavigationController的下一个页面:
ChatViewController *chatViewController = [[ChatViewController alloc] initWithNibName:@"ChatViewController" bundle:nil];
UITabBarController *homeController = self.tabBarC
[chatViewController setHomeDelegate:homeController];
[self.tabBarController.navigationController pushViewController:chatViewController animated:true];
@protocol HomeDelegate &NSObject&
-(void) onComeback:(NSString*)
@interface ChatViewController : UIViewController
@property (weak) id&HomeDelegate& homeD
@implementation ChatViewController
@synthesize homeD
[homeDelegate onComeback:@"Hello"];
[self.navigationController popViewControllerAnimated:true];
//返回导航的上一个页面
[self.navigationController popViewControllerAnimated:true];
//返回导航的第一个页面
[self.navigationController popToRootViewControllerAnimated:true];
危机公关中的珍珑棋局:天猫的内裤、星巴克的暴利与大略8点20发
危机公关中的珍珑棋局:天猫的内裤、星巴克的暴利与大概8点20发
在《天龙八部》中,逍遥派掌门无崖子有一套珍珑棋局,三四十年来都无人破解,怎么看都是死局;而虚竹硬是执子往死路走,不知觉中却已经以退为进,走出逆天之势,随后更是将整个棋局拿下,成为唯一破局者。这告诉我们或许死是另一种生,危机公关同样也可能是一场转机与重生,这要配合天时地利人和来做到,以下举三例看公关危机中的珍珑棋局:
双十一“天猫内裤案”与前段时间“星巴克暴利案”例都代表了虚竹式的前期“以退为进”与后期的“翻盘";而“8点20发”的案例则代表了慕容复之流的蛮攻所带来的必败。
这三个案例都是引发过全民狂欢的案例,具有相当大的影响力和代表性。
1、天猫“内裤案”,以退为进,化危机为营销
天猫在双十一当天发出了一条,内裤卖出两万条,连起来有3000公里长的微博。随后江宁公安的微博指出,该条微博的错误,如此算来,一条内裤长达1.5米。引发了全民吐槽。
本来这其实也是一件不算多大的事情,天猫解释一下是一盒内裤,一盒内裤有好几条,再道个歉就没了。但是天猫方面没有选择亡羊补牢的传统做法,而是自己钻出这个洞和用户打成有一片,没有选择躲在洞里。以下是天猫的回应。
天猫此次更是将马云搬出了来,把马云数学不好之类的事情拿出来自黑,直接改写了马云一直以来的形象,变成一个有血有肉甚至有点儿憨的人;而阿里系的公众形象也随之得到软化,对用户产生更强的亲和力。这种卖萌俏皮的行为很难让用户产生反感。
当然阿里并非就这一条微博,对这次内裤事件,淘宝和天猫还进行了其他诸如“央视大裤衩”、“马云数学不好”以及“给指出问题@江宁公安在线送裤衩”等调侃。天猫此次的公关好比虚竹在棋局开场时的第一次落子,放低身价,放低姿态,把自己倒空,将子落到了所有人意想不到的地方。当所有人还没有反应过来时,天猫已经开始一步步走出棋局。
2、星巴克"暴利案",柔道式翻转乾坤
央视披露星巴克的暴利后,星巴克没有被央视牵着鼻子走,没有向公证正面对自己的利润问题进行回应。而是有个小号进行了柔道式反击。
“星巴克回应央视,央视要哑火。”这句话在上个月广为流传。
回头分析这次公关,星巴克如果正面回应央视的话,那确实就是硬伤,也是星巴克的弱点。但星巴克巧妙的利用了对手的弱势,将话题搬到了对手的弱势,”对于民生的报道“上,引发了网民的极大共鸣,转而对央视进行口诛笔伐。本质上星巴克是巧妙的将商业道德伦理的指责转向了新闻媒体的伦理指责,而央视也确实在这件事情上被彻底哑火,不再做声。
星巴克好比是虚竹在棋局的第二阶段,翻转局势。对手正在强势布阵时,避其锋芒不与其正面对抗,同时找到对手的弱点以此作为自己求生的突破口,攻其不备,乱其阵脚,再揭竿而起继续痛击其软肋。赢得生存。
3、“8点20发案”,用力过猛,物极必反,反噬自身
不怕神一样的对手,就怕猪一样的队友。“大概8点20发”,可以说是315有史以来最大的乌龙球。但猪一样的队友从更宏观的意义来说又是一种必然,央视在国内从来都是一枝独秀,唯我独尊。所以何润东的"8点20发的意外"则是央视为这种孤傲所必须付出的代价。
央视的布局好比于慕容复一类在武林中有极高名望的人对于珍珑棋局的落子——傲慢让他在与对手交手时暴露弱点。央视如此庞大,在与小对手交锋时,往往船大难掉头,而小对手则可以迅速转变方向,庞大而臃肿的央视都还没来得急反应过来,甚至船已经被撞破了一个窟窿都没有察觉。
同时,慕容复一直有着和他父辈一样的帝王梦,他有一种强者为王的心理,但是到了棋局这种环境,则完全不是强者为王的规则。央视也同样如此,在传统时代,央视在中国牢牢掌控一切传播的力量,但传统时代转而进入了互联网时代,这就如同慕容复从武林进入棋局是一样的。在传统时代,你可以横扫千军,但是在互联网时代,有一种更高的规则在约束你的行为,你必须按照这些规则办事,在新规则中不是比强者为王,而是剩者为王,只有活到最后的才是胜者。
公关危机处理正面临的转变
天猫、星巴克、8点20,这三个案例,或许也预示着公关危机处理面临的未来——传统理性发言在互联网时代会越来越失去其原有价值,非理性将越来越占据上风。
第一、在自身公关危机的处理上,理性发言更显得软弱无力,必须更巧妙的使用非理性策略,以及用非理性策略去向公众言说理性。天猫此次做出了很好的表率,同样潘石屹的潘币,网易新闻客户端的道歉信都是此类的代表。
第二、在与对手博弈的公关危机中,公司越小越具备优势。星巴克完胜央视,同样,3Q大战中,360也尝尽甜头。
第三、互联网时代,大公司如果用力过猛,则反噬自身。
如果您想提高自己的技术水平,欢迎加入本站官方1号QQ群:&&,&&2号QQ群:,在群里结识技术精英和交流技术^_^
本站联系邮箱:

我要回帖

更多关于 uitabbar 的文章

 

随机推荐