当前位置:  编程技术>移动开发
本页文章导读:
    ▪UINavigationController领航控制器-视图切换        UINavigationController导航控制器-视图切换越努力.越幸福.----willingseal. UINavigationController的结构组成 -------- (1)新建一个工程,创建3个控制器类和3个视图,并关联视图和.........
    ▪ 2013 eoe挪动开发者大会,技术改变世界 会后感        2013 eoe移动开发者大会,技术改变世界 会后感话说当时是在北京国家会议中心,名字听起来很霸气啊,而且旁边屹立着水立方和鸟巢,同期举行的也有婚博会~~!不知道是什么东东? 和同学.........
    ▪ 分析Activity的View绑定历程       分析Activity的View绑定过程在我们coding时,在Activity.onCreate()里面常用的教科书式的代码是: setContentView(R.layout.main); 然后我们就可通过: View view=findViewById(R.id.helloworld); 获取某个控件,但是这.........

[1]UINavigationController领航控制器-视图切换
    来源: 互联网  发布时间: 2014-02-18
UINavigationController导航控制器-视图切换

越努力.越幸福.----willingseal.


UINavigationController的结构组成



--------

(1)新建一个工程,创建3个控制器类和3个视图,并关联视图和控制器,设置第一个view为蓝绿色,第二个view为黄色,第三个view为橘色。



(2)

    在AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColorwhiteColor];
     
    
   ListViewController * listVC= [[ListViewController  alloc] initWithNibName:@"List_iphone"bundle:nil];

    self.navController = [[UINavigationControlleralloc] initWithRootViewController:listVC];
    
     [self.windowaddSubview:self.navController.view];
   
    
    [self.windowmakeKeyAndVisible];
    returnYES;
}


(3)
点击第一个view中的button进入第二个页面
在ListViewController.m

- (void)viewDidLoad
{
    [superviewDidLoad];
// Do any additional setup after loading the view.


    self.title = @"列表";
    
      
}


- (IBAction)push:(id)sender {
    
    
    TwoViewController *twoVC = [[TwoViewControlleralloc] initWithNibName:@"Two_iphone"bundle:nil];

    
    [self.navigationControllerpushViewController:twoVCanimated:YES];
    
}
 
(4)
点击第二个view中的button进入第三个页面

在  TwoViewController.m

- (void)viewDidLoad
{
    [superviewDidLoad];
// Do any additional setup after loading the view.
    
    self.title = @"Two";
}

- (IBAction)toTwo:(id)sender {
    
    ThreeViewController *threeVC = [[ThreeViewControlleralloc] initWithNibName:@"Three_iphone"bundle:nil];
    
    [self.navigationControllerpushViewController:threeVC animated:YES];
    
    
}

(5)



(6)源代码:
点击打开链接

  




    
[2] 2013 eoe挪动开发者大会,技术改变世界 会后感
    来源: 互联网  发布时间: 2014-02-18
2013 eoe移动开发者大会,技术改变世界 会后感

话说当时是在北京国家会议中心,名字听起来很霸气啊,而且旁边屹立着水立方和鸟巢,同期举行的也有婚博会~~!不知道是什么东东?

和同学一起去,当时人山人海,可见大家投身于移动互联网的热情一斑!

有图有真相:先上几张图.

议程可以参考几张图片



在这里就说一下自己的感悟:


上午:主论坛


  • 靳(jin)岩,eoe Founder&CEO

里面有一句触动我:

D.R.Y,Don't repeat your self

不要重复自己,不要总是用同一种方式做一件事情,因为这么做的话没有成长。


详见:

靳岩:从码农到极客的升级之路

http://tech2ipo.com/61534

  • 小米,开源硬件讲解

推荐了几个众筹网站:

http://www.indiegogo.com/

点名时间,国内

http://www.demohour.com/

国外比较有名的:

http://www.kickstarter.com/


以及一本关于创客的书《Makers》

下午:应用论坛


  • 王军,Testin创始人&CEO
智能手机待机时间长;应用APP启动时间<300ms,腾讯QQ无疑是霸主;测试的时候,推荐CPU使用单核

  • 小米公司技术分享 汪超骏,Fuubo开发者

联创团队成员:

上百度百科查了一下:

http://baike.baidu.com/view/1563648.htm

这个团队感觉就是中国的春天,

http://www.hustunique.com/

以及爱范儿的一篇采访:

http://www.ifanr.com/267526


具体内容查看:

UI Performance & MIUI.pdf

http://download.csdn.net/detail/jptiancai/6287923

  • 透过豌豆荚设计奖看应用的好气质

动画:自然、统一,短促、平滑

引用了IDEO著名设计公司的理念,创新出自己的设计

设计-渴求度

创造性地解决问题

技术-可行度

商业-价值度


评价:

出色满足某个特定需求。如有道APP的拍照翻译,Human-打开界面,只有分钟,帮用户省心,用户体验非常好


符合android设计规范(推荐官方的) 7×7游戏(andrioid卡片,符合规范),不推荐的就是腾讯的微信,在android平台下仍然是ios的操作体验,的确很不爽。


有一些令人着迷,为之倾心的细节(存钱APP,存钱的时候弹出硬币的声音;字节社,文字排版)

技术驱动 chrome手机浏览器-突出快

字节社-排版技术非常好!

  • android高性能实践
详情请见
http://huati.weibo.com/k/eoe%E7%A7%BB%E5%8A%A8%E5%BC%80%E5%8F%91%E8%80%85%E5%A4%A7%E4%BC%9A?from=object&order=time&filter=atten

【完】


    
[3] 分析Activity的View绑定历程
    来源: 互联网  发布时间: 2014-02-18
分析Activity的View绑定过程
在我们coding时,在Activity.onCreate()里面常用的教科书式的代码是:
setContentView(R.layout.main);
然后我们就可通过:
View view=findViewById(R.id.helloworld);
获取某个控件,但是这一切是如何完成的,本文会去探讨一下。
进入Activity的源码,查看setContentView()和findViewById()这两个函数查看原型:
     /***
     * Set the activity content from a layout resource.  The resource will be
     * inflated, adding all top-level views to the activity.
     *
     * @param layoutResID Resource ID to be inflated.
     */
     public void setContentView( int layoutResID) {
        getWindow().setContentView(layoutResID);
    }
     /***
     * Set the activity content to an explicit view.  This view is placed
     * directly into the activity's view hierarchy.  It can itself be a complex
     * view hierarhcy.
     *
     * @param view The desired content to display.
     */
     public void setContentView(View view) {
        getWindow().setContentView(view);
    }
他们都是通过getWindow()获得一个Windows的实例化对象的相关方法。
Window是个抽象类。这个Window的子类是什么呢?

是PhoneWindow,至于为什么是它,这里暂不讨论。有兴趣的同学可以查看这篇博客:

http://www.cppblog.com/fwxjj/archive/2013/01/13/197231.html

下面我们进入PhoneWindow的源码看一看。PhoneWindow在com.android.internal.policy.impl包下面。
    @Override
    public void setContentView(int layoutResID) {
        if (mContentParent == null) {
            installDecor();
        } else {
            mContentParent.removeAllViews();
        }
        mLayoutInflater.inflate(layoutResID, mContentParent);
        final Callback cb = getCallback();
        if (cb != null && !isDestroyed()) {
            cb.onContentChanged();
        }
    }
上面是setContentView在PhoneWindow里的实现,而findViewById()在Window里面实现:
    /**
     * Finds a view that was identified by the id attribute from the XML that
     * was processed in {@link android.app.Activity#onCreate}.  This will
     * implicitly call {@link #getDecorView} for you, with all of the
     * associated side-effects.
     *
     * @return The view if found or null otherwise.
     */
    public View findViewById(int id) {
        return getDecorView().findViewById(id);
    }
下面我们挨个分析,首先是setContent(),其中关键的代码是这行:
mLayoutInflater.inflate(layoutResID, mContentParent);
它将layoutResID所指向的布局实例化成view然后挂在了mContentParent后面。挂接上去之后剩下的就是view的绘制工作了,这个按下不表。
接着是findViewById(),它是调用DecorView.findViewById()。DecorView是PhoneWindow的内部类,它表示整个window的顶层view,默认情况下它有两个子view,一个就是显示灰色的标题(也就是titlebar),另一个就是程序的显示区域。关于DecorView更详细的资料,大家可以参考:http://www.cnblogs.com/beenupper/archive/2012/07/13/2589749.html
DecorView其实是FrameLayout的子类,跟进FrameLayout!!!FrameLayout里面没发现findViewById().....进入FrameLayout的父类ViewGroup还是没有发现,继续深入...直到View。Bingo!
 /**
     * Look for a child view with the given id.  If this view has the given
     * id, return this view.
     *
     * @param id The id to search for.
     * @return The view that has the given id in the hierarchy or null
     */
    public final View findViewById(int id) {
        if (id < 0) {
            return null;
        }
        return findViewTraversal(id);
    }
它非常爽快的调用了findViewTraversal(),但是注意ViewGroup是Override了这个方法的,所以需要进入ViewGroup查看findViewTraversal()。
    /**
     * {@hide}
     */
    @Override
    protected View findViewTraversal(int id) {
        if (id == mID) {
            return this;
        }
 
        final View[] where = mChildren;
        final int len = mChildrenCount;
 
        for (int i = 0; i < len; i++) {
            View v = where[i];
 
            if ((v.mPrivateFlags & PFLAG_IS_ROOT_NAMESPACE) == 0) {
                v = v.findViewById(id);
 
                if (v != null) {
                    return v;
                }
            }
        }
 
        return null;
    }
这里还是有地方需要注意的:
首先是:
         if (id == mID) {
             return this ;
        }
mID是本View的ID,也就是说findViewById()是可以find到baseview的。然后就是:
         final View[] where = mChildren;
         final int len = mChildrenCount;
         for ( int i = 0 ; i < len; i ++ ) {
            View v = where[i];
 
             if ((v.mPrivateFlags & PFLAG_IS_ROOT_NAMESPACE) == 0 ) {
                v = v.findViewById(id);
 
                 if (v != null) {
                     return v;
                }
            }
        }
         return null;
获取ViewGroup的所有子view,然后循环的查询子view中是否有view.getId()==id。这里其实还隐藏了一个递归过程,在<Android的UI两大基石>中,我们知道View和ViewGroup是使用Composite的组合模式,ViewGroup是View的子类。所以v.findViewById()可能调用View或者ViewGroup的findViewById(),这里也贴上View.findViewById()的源码。
    /**
     * Look for a child view with the given id.  If this view has the given
     * id, return this view.
     *
     * @param id The id to search for.
     * @return The view that has the given id in the hierarchy or null
     */
    public final View findViewById(int id) {
        if (id < 0) {
            return null;
        }
        return findViewTraversal(id);
    }
View.findViewById()只是检查id是不是等于View自己的id,这样就保证了这个深度优先遍历的收敛性。
通过findViewById()我们知道了在Activity里面使用findViewById()其实是调用DecorView这个Window的顶层view的findViewById();
我们更知道了为什么有的时候findViewById()会返回null,为什么我们有的时候需要指定findViewById()的baseView,形如:
baseView.findViewById(R.id.helloworld);

--------------------------------------------

如果文中有任何错误,欢迎指出。


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
NOSQL iis7站长之家
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3