Is this an example of an iOS UITableView?
I need to do something like this :
.Is it a UITableView
? Or how should I do this? Any idea is welcome.
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
if (indexPath.row == 0) return cell1;
} else if (indexPath.section == 1) {
if (indexPath.row == 0) return cell2;
} else if (indexPath.s开发者_StackOverflow中文版ection == 2) {
if (indexPath.row == 0) return cell3;
}
}
Most likely its a UITableView. May be its not (it can be a UIScrollView with views added like sections in a table view).
But if you want to create something like in the image, I'd suggest you to use UITableView with customized cells. Because implementing table view, in this case, is simpler as you have to just concern about the delegate and the dateSource of the table view, rather than worrying about aligning the views in order.
Use sectioned table view with the translucent, gray-bordered, black-background-view as the backgroundView of the cells. Add the labels and arrow as the subviews of cell. You can add arrow as the accessoryView but that would become vertically centered, but in the image the arrow is displayed slightly on top of the cell.
There should be only one cell in each section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
There can be any number of sections (3 here).
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3; // Can be any number
}
Yes, that's most likely a styled table view. See this guide or this nice tutorial.
why you worry about this one? Its simple man.... its nothing ,if you have hands over UITableView. Yeah, You must know about : 1: Set background image on view,exact as table size. 2: Set table view onto them and make background transparent. 3: Make customize table cell and add to table' row.
Thats it.....enjoy this work..its a creativity. And you can do it guy....
I cannot tell exactly what is used from the picture, however I suggest using the UITableView especially if you have variable data coming from a structured object.
Some tutorials which I found very useful are the following:
Creating customized UITableViewCell from XIB
http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder/
UIViewTable anti-patterns - A very good MVC pattern to build UIViewTable
http://www.slideshare.net/nullobject/uitableviewcontroller-antipatterns
And of course Apple's docs:
http:/developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html
One important fact to remember is that you should always reuse cached table cells through the datasource method tableView:didSelectRowAtIndexPath:
Note: Since you want lots of transparencies there might be some performance issue especially on older devices.
Hope this helps and goodluck with your project.
There is not need to its scrollview or tableview... both are perform same..
Just change the Background Color of Tableview as clear color.....
check this code...
put this line to viewDidLoad :
[tableView setBackgroundColor:[UIColor clearColor]];
and
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
..... // Your label buttons etc........ ...... ...... .....
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell setClipsToBounds:YES];
[[cell layer] setBorderColor:[[UIColor blackColor] CGColor]];
[[cell layer] setCornerRadius:10];
}
You can do this using tableView in
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//here place return your array contents
}
We can accomplish the similar as shown in image above by Table View and scroll view both.If you don't want to use table view then you can take a scroll view or a simple view and can add several buttons along with the image in background with different frames.It means button background will have the same image.then you can use different labels to show all the texts in different labels according to the requirement. OR you can use table view.For this you need to return number of sections 3(in this image) in the delegate method - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView.and then everything as the default tableview style.And then change the cell style to detailed.
yes this is a tableView with custom UITableViewCell.you can do that by creating a empty xib file and then add a UITableViewCell and do your customizing ...then in cellForRowAtIndexPath method use:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:edentifier];
if (cell == nil) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"yourCellName" owner:self options:nil]objectAtIndex:0];
this is from my application.
Yes, it is a groupedtableview
with clearcolor
as backgroundcolor
. Cell background color also needs to be changed to clearcolor
.
I suggest using div or list, don't use table, its very hard to control if the contents are too long.
精彩评论