iOS--(UITableViewCell)、(UITableViewController)微信個人首頁,uitableviewcell

來源:互聯網
上載者:User

iOS--(UITableViewCell)、(UITableViewController)個人首頁,uitableviewcell

本文主要實現了的個人首頁的設定:

目錄檔案如下:

 

 

實現代碼如下:

 

 

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=@"往事隨風 \r\n號: 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

 

如下:

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.