• iOS--(UITableViewCell)、(UITableViewController)微信个人主页


    本文主要实现了微信的个人主页的设置:

    目录文件如下:

    实现代码如下:


    RootTableViewController.h

    #import <UIKit/UIKit.h>
    @interface RootTableViewController : UITableViewController
    @property(strong,nonatomic) NSArray
    *arrtitle; @property(strong,nonatomic) NSArray *arrimage; @end

    RootTableViewController.m

    #import "RootTableViewController.h"
    
    @interface RootTableViewController ()
    
    @end
    
    @implementation RootTableViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.title=@"";
        self.arrtitle=@[@"相册",@"收藏",@"钱包",@"卡包"];
        self.arrimage=@[@"MoreMyAlbum@3x",@"MoreMyFavorites",@"MoreMyBankCard@3x",@"PayCarddetailVirtualIcon@2x"];
        
        [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"mycell"];
        self.tableView.scrollEnabled=NO;
    
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        
    }
    
    #pragma mark - Table view data source
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
        return 4;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        if (section==0) {
            return 1;
        }else if (section==1){
            return 4;
        }else{
        return 1;
        }
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mycell" forIndexPath:indexPath];
        if (indexPath.section==0) {
            cell.textLabel.numberOfLines=2;
            cell.textLabel.text=@"往事随风 
    微信号: angle-l-520";
            cell.imageView.frame=CGRectMake(0, 0, 20, 20);
            cell.imageView.image=[UIImage imageNamed:@"a.jpeg"];
            
            //添加二维码照片
            UIImageView *a=[[UIImageView alloc]initWithFrame:CGRectMake(350, 55, 50, 50)];
            [a setImage:[UIImage imageNamed:@"add_friend_myQR"]];
            [tableView addSubview:a];
    
        }else if (indexPath.section==1){
            cell.textLabel.text=self.arrtitle[indexPath.row];
            cell.imageView.image=[UIImage imageNamed:self.arrimage[indexPath.row]];
        }else if(indexPath.section==2){
            cell.textLabel.text=@"表情";
            cell.imageView.image=[UIImage imageNamed:@"MoreExpressionShops@3x"];
            
        }else{
            cell.textLabel.text=@"设置";
            cell.imageView.image=[UIImage imageNamed:@"MoreSetting@3x"];
        }
        
        if (indexPath.section==0) {
            cell.accessoryType=UITableViewCellAccessoryNone;
        }else{
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        }
        
        return cell;
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
    {
        if (indexPath.section==0) {
            return 100;
        }
        return 50;
    }
    .....
    @end

    AppDelegate.h

    #import <UIKit/UIKit.h>
    #import "RootTableViewController.h"
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    @end

    AppDelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window.rootViewController=[[UINavigationController alloc] initWithRootViewController:[[RootTableViewController alloc] initWithStyle: UITableViewStyleGrouped ]];
    
        return YES;
    }
    
    @end

    效果图如下:

  • 相关阅读:
    国内常用开源镜像
    spring中用到的常用设计模式
    微服务时代之网关及注册中心高可用架构设计
    查找字符串中相同连续字符串最多的子串,如果有两串长度相同取asc码 例如1233455 中是33
    mysql规范
    spring boot实现AOP登录拦截
    索引的类型及分类
    Im4java+ImageMagick/GraphicsMagick
    phpMyAdmin 应用程序“DEFAULT WEB SITE”中的服务器错误
    真机安装centos
  • 原文地址:https://www.cnblogs.com/bolin-123/p/5289841.html
Copyright © 2020-2023  润新知