swift跳转后,导航条未有了

2020-01-23 19:44栏目:竞技宝app
TAG:

网上了oc的例子,请问swift该怎么办,谢谢TLDLoginViewController*loginVC=[[TLDLoginViewControlleralloc]init];TLDNavigationController*nv=[[TLDNavigationControlleralloc]initWithRootViewController:loginVC];//将普通视图添加到NavigationController[selfpresentViewController:nvanimated:YEScompletion:^{NSLog(@"模态视图");}];

//// LeftMenuViewController.m// StarrySky//// Created by RickyWei on 2017/10/30.// Copyright © 2017年 BW. All rights reserved.//#import "LeftMenuViewController.h"#import "LoginViewController.h"#import "PersonViewController.h" //个人信息控制器#import "CollectionViewController.h" //我的收藏#import "AboutUsViewController.h" //关于我们@interface LeftMenuViewController (){

NSArray *_tableDatas;//表格数据

}

//头像视图

@property(nonatomic,strong)UIImageView *headImgView;

//账号label

@property(nonatomic,strong)UILabel *accountLabel;

//表格

@property(nonatomic,strong)UITableView *table;

//登录视图控制器

@property(nonatomic,strong)LoginViewController *loginVC;

@end

@implementation LeftMenuViewController

#pragma mark ------- 控制器实例化 ----------

-(LoginViewController *)loginVC{

if (!_loginVC) {

_loginVC = [[LoginViewController alloc]init];

}

return _loginVC;

}

#pragma mark ------- 控件实例化 ----------

//头像视图

-(UIImageView *)headImgView{

if (!_headImgView) {

_headImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, FIT_X(80), FIT_X(80))];

_headImgView.center = CGPointMake(SCREEN_W/4+FIT_X(50), FIT_Y(104));

_headImgView.clipsToBounds = YES;

_headImgView.layer.cornerRadius = FIT_X(40);

_headImgView.image = [UIImage imageNamed:@"40"];

_headImgView.userInteractionEnabled = YES;

_headImgView.contentMode =  UIViewContentModeScaleAspectFill;

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headImgDidHandle:)];

[_headImgView addGestureRecognizer:tap];

}

return _headImgView;

}

//账号标签

-(UILabel *)accountLabel{

if (!_accountLabel) {

_accountLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, FIT_X(300), FIT_Y(30))];

_accountLabel.center = CGPointMake(self.headImgView.center.x, self.headImgView.center.y + self.headImgView.frame.size.height / 2 + FIT_Y(15) + FIT_Y(20));

_accountLabel.textAlignment = NSTextAlignmentCenter;

_accountLabel.text = @"18911121441";

_accountLabel.textColor = [UIColor whiteColor];

_accountLabel.font = [UIFont systemFontOfSize:18.];

}

return _accountLabel;

}

//选项表格

-(UITableView *)table{

if (!_table) {

_table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, FIT_X(300), 200) style:UITableViewStylePlain];

_table.rowHeight = 50;

_table.center = CGPointMake(self.headImgView.center.x, self.accountLabel.center.y + self.accountLabel.frame.size.height / 2 + 100 + FIT_Y(20));

_table.scrollEnabled  = NO;

_table.backgroundColor = [UIColor clearColor];

_table.dataSource = self;

_table.delegate = self;

}

return _table;

}

#pragma mark - --- UITableViewDelegate ----

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

switch (indexPath.row) {

case 0:  //个人信息

[self headImgDidHandle:nil];

break;

case 1:  //我的收藏

{

if ([[UserDataBase shaerDataBase]userHadLogin]) {

CollectionViewController *collVC = [[CollectionViewController alloc]initWithTag:BaseViewControllerTag_Left];

UINavigationController *collNav = [[UINavigationController alloc]initWithRootViewController:collVC];

collVC.navigationItem.title = @"我的收藏";

[self presentViewController:collNav animated:YES completion:nil];

}

else

{

[self presentViewController:self.loginVC animated:YES completion:nil];

}

}

break;

case 2:  //关于我们

{

AboutUsViewController *usVC = [[AboutUsViewController alloc]initWithTag:BaseViewControllerTag_Left];

UINavigationController *usNav = [[UINavigationController alloc]initWithRootViewController:usVC];

usVC.navigationItem.title = @"关于我们";

[self presentViewController:usNav animated:YES completion:nil];

}

break;

case 3:  //退出登录

{

//底层数据库业务退出

[[UserDataBase shaerDataBase]logOut];

//更新菜单视图UI

[self updateAllUI];

//发出一个退出登录的通知

[[NSNotificationCenter defaultCenter] postNotificationName:LOGOUT_NOTIFICATION_NAME object:nil];

}

break;

default:

break;

}

}

#pragma mark ----UITableViewDataSource ----

版权声明:本文由龙竞技官网发布于竞技宝app,转载请注明出处:swift跳转后,导航条未有了