代码搭建记事本框架(一)

纠结数天,终于下定决心开始搭建属于自己的记事本。

写在最前面:这两天是有些彷徨,加上重感冒,难受的要死。思路有些混乱,界面想了一下大概,就胡乱的开始了。但是总算是迈出了第一步。

将rootviewcontroller设置为tabbar

   application.statusBarHidden = YES;
    
    self.window = [[UIWindow alloc]init];
    self.window.frame = [[UIScreen mainScreen]bounds];
    
    self.window.rootViewController = [[CSMainBarController alloc]init];
    
    [self.window makeKeyAndVisible  ];

 

 

采用的tabbarcontroller 上面套上uinavcontroller  在加上tableviewcontroller 代码如下:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    CSMineTableViewController *mineTabelview = [[CSMineTableViewController alloc]init];
    CSMineTableViewController *mineTable =[[CSMineTableViewController alloc ]init];
    [self setTabbarController:mineTable Title:@"关于我" image:@"tabbar_profile_os7" selectImage:@"tabbar_profile_selected"];
    CSDiaryTableViewController *diaryTable = [[CSDiaryTableViewController alloc]init];
    [self setTabbarController:diaryTable Title:@"哈哈" image:@"tabbar_profile_os7" selectImage:@"tabbar_profile_selected"];
    
    CSSettingViewController *setView = [[CSSettingViewController alloc]init];
    [self setTabbarController:setView Title:@"饿了" image:@"tabbar_profile_os7" selectImage:@"tabbar_profile_selected"];
    
    CSDuanZiViewController *duanzi  = [[CSDuanZiViewController alloc]init];
    [self setTabbarController:duanzi Title:@"饿了" image:@"tabbar_profile_os7" selectImage:@"tabbar_profile_selected"];
}
/**
 *   设置对应的tabbar的属性
 *
 *  @param childVC     <#childVC description#>
 *  @param tile        <#tile description#>
 *  @param image       <#image description#>
 *  @param selectImage <#selectImage description#>
 */
-(void)setTabbarController:(UIViewController *)childVC Title:(NSString *)tile image:(NSString *)image selectImage: (NSString *)selectImage
{
//    childVC.title  =tile;
//    childVC.tabBarItem.image = [UIImage imageNamed:image];
//    childVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];

    childVC.view.backgroundColor = CSRandomColor;
    childVC.tabBarItem.title = tile;
    childVC.tabBarItem.image = [UIImage imageNamed:image];
    childVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
    [self addChildViewController:childVC];
    
    CSNavigationViewController *myNav =[[CSNavigationViewController alloc]initWithRootViewController:childVC];
    [self addChildViewController:myNav];
}

 

通过重构nav中的push方法来判断对应的数据:判断通过push的viewcontroller是不是存在,count>0将隐藏对应的tabbar

/**
 *  拦截push进来的视图
 *
 */
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count>0) {   //如果push进来的不是栈底控制器的话
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:YES];
}

 

 

给对应的子视图设置对应的伪数据,并且做好相应的点击时间的跳转:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 20;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString * ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID ];
    
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"我是第 %ld",(long)indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *myView = [[UIViewController alloc]init];
    myView.view.backgroundColor = [UIColor redColor];
    myView.title = @"diary跳转";
    [self.navigationController pushViewController:myView animated:YES];
}

 

对应顶部的UIBarButtonItem的点击,建立对应UIBarButtonItem的分类

//重构代码实现点击
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"navigationbar_friendsearch" highImage:@"navigationbar_friendsearch_highlighted" target:self action:@selector(pop)];


-(void)pop
{
    UIViewController *aboutView = [[UIViewController alloc]init];
    [aboutView.view setBackgroundColor:[UIColor redColor]];
    [self.navigationController pushViewController:aboutView animated:YES];
}

分类中对应的代码:

+(UIBarButtonItem *)itemWithImage:(NSString *)imageName highImage:(NSString *)highImage target:(id)target action:(SEL)action
{
    UIButton *button = [[UIButton alloc]init];
//    button  setImage:imageName forState:<#(UIControlState)#>
    [button   setBackgroundImage:[UIImage imageNamed:imageName ] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    
//    button.frame.size = button.currentBackgroundImage.size;
    CGRect frame = button.frame;
    frame.size = button.currentBackgroundImage.size;
    button.frame = frame;
    
    [button   addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc]initWithCustomView:button];

}
记事本资讯网站源码简介 记事本资讯网站源码采用织梦discuz基于php mysql制作,功能是毋庸置疑的,强大至极。源码完整无错,本站修复源码的大量模板错位问题,现已完美分享,需要的朋友请拿走! 记事本资讯网站源码安装教程: 、将整站解压后,将文件夹内的所有文件上传到网站根目录(西部数码的根目录是:wwwroot,不同网站的根目录名称不同,请咨询空间提供商,不要来问我) 注意:如果您的空间支持在线解压的话,建议您直接将压缩文件上传解压,因为这样速度会很快,也很少会出错。 二、打开浏览器,在地址栏里输入http://网址/install/index.php 点击安装 至此Discuz x3.x程序安装完成。 三、登录Discuz后台(http://域名/admin.php) 选择 "站长—数据库—恢复—导入" 或者 http://您的域名/data/restore.php 四、检查UCenter能否登陆 1、检查UCenter 访问地址设置是否正确(般不会出错) 2、创始人密码和admin管理员密码有可能不是同个,创始人密码是上面第二步重新安装discuz程序时设置的密码。 3、检查UCenter应用是否通讯成功 五、在后台:工具 更新缓存 完毕。 六、恢复完的后台 管理员帐号:admin 密码:1 如果不清楚可以下载后看里面具体的安装教程 记事本资讯网站源码前台页面 记事本资讯网站源码后台管理 后台路径:http://域名/admin.php 用户名与密码:安装时可设置 后台页面 相关阅读 同类推荐:站长常用源码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值