开源中国社区iOS客户端学习-(2)侧拉栏和设置界面
发布日期:2022-02-01 13:46:26
浏览次数:37
分类:技术文章
本文共 2449 字,大约阅读时间需要 8 分钟。
上一篇中提到
self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuViewController"];
其中leftMenuViewController即为侧拉栏的storyboard ID,在storyboard中找到这个tableViewController,可以发现它的class是SideMenuViewController。
再用一次上一篇中的图 可以在viewDidLoad进行一些设置,让界面更加美观self.tableView.backgroundColor = [UIColor titleBarColor];//设置背景颜色 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//tableView无分割线 self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];//除去多余行
侧拉栏使用表视图构建,可以分成两个部分。
1)section的header用来创建“点击头像登录”- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 160;//设置高度}- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ ...... return headerView;}
2)为普通的tableViewCell,放置具体的选项。先看一下“设置”选项。
case 3: { SettingsPage *settingPage = [SettingsPage new]; [self setContentViewController:settingPage]; break; }
通过调用setContentViewController:转到设置界面
- (void)setcontentViewController:(UIViewController *)viewController{ viewController.hidesBottomBarWhenPushed = YES;//跳转时隐藏TabBarController的BottomBar UINavigationController *nav = (UINavigationController *)((UITabBarController *)self.sideMenuViewController.contentViewController).selectedViewController;//将nav设置为已选的contentViewController [nav pushViewController:viewController animated:NO]; [self.sideMenuViewController hideMenuViewController];//隐藏侧拉栏}
不登陆时,设置界面共有五个选项。点击“清除缓存”选项只会弹出警告框,并没有真正作用(说不对的话,请不要打我),点击“给应用评分”选项跳转到App Store。
if (section == 0) { if (row == 0) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"确定要清除缓存的图片和文件?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alertView show]; } else if (row == 1){ } } else if (section == 1) { if (row == 0) { [self.navigationController pushViewController:[FeedbackPage new] animated:YES]; } else if (row == 1) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/kai-yuan-zhong-guo/id524298520?mt=8"]];//点击“给应用评分”选项跳转到App Store } else if (row == 2) { [self.navigationController pushViewController:[AboutPage new] animated:YES]; } else if (row == 3) { [self.navigationController pushViewController:[OSLicensePage new] animated:YES]; }
转载地址:https://blog.csdn.net/shidesheng5435/article/details/49453493 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年03月24日 12时05分43秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
cmd命令行实用技巧_CodingPark编程公园
2019-04-26
数据可视化与文本分类_CodingPark编程公园
2019-04-26
数据分析之数据可视化_CodingPark编程公园
2019-04-26
隐马尔可夫模型的样本生成&模型训练&预测_CodingPark编程公园
2019-04-26
SpringBoot快速入门_CodingPark编程公园
2019-04-26
命名实体识别_CodingPark编程公园
2019-04-26
Ajax+SpringBoot注册登录实战_CodingPark编程公园
2019-04-26
光纤猫连接路由器_CodingPark编程公园
2019-04-26
信息抽取_CodingPark编程公园
2019-04-26
如何理解输入流输出流?_CodingPark编程公园
2019-04-26
Python类|实例|方法|继承_专题_CodingPark编程公园
2019-04-26
机器学习心得_CodingPark编程公园
2019-04-26
自然语言工程师心得概述_CodingPark编程公园
2019-04-26
for循环那点事儿_CodingPark编程公园
2019-04-26
Int -> List | List -> Int _ CodingPark编程公园
2019-04-26
如何在junit中使用SpringFramework的Ioc容器
2019-04-26
一个案例教你理解Spring面向切面编程(Spring Aop)
2019-04-26
手把手教你整合SSM框架
2019-04-26
自己造个简单数据校验的注解@Value和@Mail
2019-04-26
Poj百练 4148:生理周期 (分类:枚举)
2019-04-26