IOS -- (UITableViewCell), (UITableViewController) WeChat personal homepage, uitableviewcell

Source: Internet
Author: User

IOS -- (UITableViewCell), (UITableViewController) personal homepage, uitableviewcell

This article mainly sets the personal homepage:

The directory file is as follows:

 

 

The implementation code is as follows:

 

 

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 = @ "I"; self. arrtitle = @ [@ "album", @ "favorites", @ "wallet", @ "card pack"]; self. arrimage = @ [@ "MoreMyAlbum @ 3x", @ "MoreMyFavorites", @ "MoreMyBankCard @ 3x", @ "PayCarddetailVirtualIcon @ 2x"]; [self. tableView registerClass: [UITableViewCell class] forCellReuseIdentifier: @ "mycell"]; self. tableView. scrollEnabled = NO;}-(void) didReceiveMemoryWarning {[super success];} # 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 cell: @ "mycell" forIndexPath: indexPath]; if (indexPath. section = 0) {cell. textLabel. numberOfLines = 2; cell. textLabel. text = @ "The wind \ r \ n: angle-l-520"; cell. imageView. frame = CGRectMake (0, 0, 20, 20); cell. imageView. image = [UIImage imageNamed: @ "a.jpeg"]; // Add a QR code photo to 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 = @ "Emotion"; cell. imageView. image = [UIImage imageNamed: @ "MoreExpressionShops @ 3x"];} else {cell. textLabel. text = @ "set"; 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

 

As follows:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.