아이폰강의(6) pdf
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,260
On Slideshare
990
From Embeds
270
Number of Embeds
3

Actions

Shares
Downloads
10
Comments
0
Likes
0

Embeds 270

http://www.sunoo.net 200
http://sunoo.net 68
http://denny0326.tistory.com 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Chapter 8 Custom TableView Cell Bit Academy
  • 2. • • NIB . • NIB Top Level . • .
  • 3. • , , . • . • UITableViewCell .
  • 4. IB NIB
  • 5. NIB• File->New IOS User Interface View Next PhotoTableCell• PhotoTableCell.xib• PhotoTableCell.xib IB View TableViewCell TableViewCell UIImageView, UILabel .• UIImageView Mode Aspect To Fit .
  • 6. • IB • IB IBOutlet property • viewWithTag: • Tag 0 .
  • 7. • tableView: cellForRowAtIndexPath: , PhotoTableCell.nib tag • nib ( ) • [NSBundle mainBundle]
  • 8. NSBundle Class • NSBundle . • mainBundle : NSBundle . + (NSBundle *)mainBundle • - (NSArray *)loadNibNamed:(NSString *)name owner: (id)owner options:(NSDictionary *)options name category NSBundle nib The name of the nib file, which need not include the .nib extension. owner :nib Files Owner object. options : A dictionary containing the options to use when opening the nib file. For a list of available keys for this dictionary, see “Nib File Loading Options. Nib Toplevel ( root View 0 .)
  • 9. tableView: cellForRowAtIndexpath: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[self appDelegate].photoArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PhotoTableCell" owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; // } ! NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row]; ! ! // cell.textLabel.text = [photoData valueForKey:@"Country"]; ! // cell.detailTextLabel.text = [photoData valueForKey:@"Region"]; ! // cell.imageView.image = [photoData valueForKey:@"Thumbnail"]; UIImageView *imageView = (UIImageView *) [cell viewWithTag:1]; imageView.image = [photoData valueForKey:@"Thumbnail"]; UILabel *label; label = (UILabel *) [cell viewWithTag:2]; label.text = [photoData valueForKey:@"Country"]; label = (UILabel *) [cell viewWithTag:3]; label.text = [photoData valueForKey:@"Region"]; ! cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; }
  • 10. • RootViewController.xib Tableview Row height PhotoTableCell.xib height .