iOS7 after the new upgrade, the interface has changed greatly, the Xcode simulator removed the phone border and home button, if you want to go back to the main page, you can press and hold the Shift+comment+r key. Talk less nonsense first show the effect of UITableView set to group under the new UI:
The overall interface is more concise, and the UITableViewCell width defaults to full graphic, and rounded corners are also canceled.
The following is a procedure for customizing UITableView:
First, drag a uiimageview and two labels to the cell in the storyboard.
Then create a new MyCell class that inherits from UITableViewCell.
MyCell Code:
#import <UIKit/UIKit.h> @interface mycell:uitableviewcell *myimageview; *Namelabel; *TimeLabel; @end
#import"MyCell.h"@implementation MyCell-(ID) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) Reuseidentifier { self=[Super Initwithstyle:style Reuseidentifier:reuseidentifier]; if(self) {//Initialization Code } returnSelf ; } - (void) setselected: (BOOL) selected animated: (bool) animated {[Super setselected:selected animated:animated]; //Configure The View for the selected state} #pragmaMark sets the cell's border width-(void) Setframe: (CGRect) frame {frame.origin.x+=Ten; Frame.size.width-= A*Ten; [Super Setframe:frame]; } @end
Use:
Used in Uitableviewcontroller, the code is as follows:
#import"RootViewController.h"#import"MyCell.h"@interface Rootviewcontroller () @end @implementation Rootviewcontroller-(ID) Initwithstyle: (Uitableviewstyle) style { self=[Super Initwithstyle:style]; if(self) {//Custom Initialization } returnSelf ; } - (void) viewdidload {[Super viewdidload]; } - (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated. } #pragmaMark-table View Data Source-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView {return 2; } -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {return 3; } -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {StaticNSString *cellidentifier =@"Cell"; MyCell*cell =[TableView dequeuereusablecellwithidentifier:cellidentifier Forindexpath:indexpath]; if(cell==Nil) {Cell=[[MyCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } Cell.nameLabel.text=@"Wildcat"; Cell.timeLabel.text=@"2013-11-7"; returncell; } -(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{return the. F; } @end
The modified effect:
Of course, if you like the cell full screen effect, you can absolutely not set the cell width ...
Fast, easy, and efficient way to implement custom Tableviewcell in IOS-Pro-Test version-Elite edition