5 Android/IOS主页:Activity /Fragment/AppManager 与 UITabBarController/UINavigationController

Android 类似微信主页的实现:
MainActivity + 4 个Fragment
主要用到 ViewPager + FragmentPagerAdapter
页面布局 + 适配器
建立4个Fragment 给到 FragmentPagerAdapter , 适配ViewPager 即可
Fragment 依赖 MainActivity 的生命周期
【数组管理】


IOS 类似微信主页的实现:
1 UITabBarController  标签页,也是继承自UIViewController
属性包括数组NSArray viewControllers  和单个VC selectedViewController
也就是几个(home mine)的页面列表,和当前选中的页面
我们新建各个页面的VC, 设置到vcs 数组中即可
最后UITabBarController 作为keywindow.rootViewController 存在即可
【数组管理】

2 UINavigationController 导航页,也是继承自UIViewController
同样有一个NSArray 的viewControllers, 不同是的,单个VC 是topViewControllers
通过栈的形式管理VC, [initWithRootViewController: homeViewController];
初始化时,传入home mine 的VC, 作为栈底VC,之后push /pop新的VC,最终均是返回到栈底VC中、
总结:四个普通VC,通过UINavigationController 的封装,给到UITarbarController 标签页
【栈管理】


对于页面管理
IOS 基于UINavigationController 的栈管理,pop, push
Android 或者自己finish , 或者建立AppManager 【栈管理】
使用 Stack<Activity> 管理
在根 BaseActivity中 ,onCreate add  stack.add(activity);
onDestroy 中 remove
stack.remove(activity)  
activity.finish;
acitivity = null;  

猜你喜欢

转载自blog.csdn.net/qq_42022061/article/details/88529657