samvermette's उत्तर के आधार पर, लेकिन एक UITableViewCell सबक्लास से छवि को कंपोजिट करने के बजाय सीधे पृष्ठभूमि छवि का उपयोग करने के लिए संशोधित किया गया। सैम का जवाब अच्छा है, लेकिन यह सीधे पृष्ठभूमि छवि बनाने से कम प्रदर्शन करेगा।
एक UIView उपवर्ग बनाएं - इस उदाहरण में मैं इसे CustomTiledView कहा जाता है - और वर्ग के लिए निम्न कोड जोड़ें:
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"tableview_empty_cell_image"];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM (context, 1, -1);
CGContextDrawTiledImage(context,
CGRectMake(0, 0, rect.size.width, image.size.height),
[image CGImage]);
}
अपने tableviewcontroller लिए निम्न कोड जोड़ें:
- (CGFloat)tableView:(UITableView *)tableView
heightForFooterInSection:(NSInteger)section {
// this can be any size, but it should be 1) multiple of the
// background image height so the last empty cell drawn
// is not cut off, 2) tall enough that footer cells
// cover the entire tableview height when the tableview
// is empty, 3) tall enough that pulling up on an empty
// tableview does not reveal the background.
return BACKGROUND_IMAGE_HEIGHT * 9; // create 9 empty cells
}
- (UIView *)tableView:(UITableView *)tableView
viewForFooterInSection:(NSInteger)section {
CustomTiledView *footerView = [[CustomTiledView alloc] init];
return [footerView autorelease];
}
अंत में, आपको -tableView:heightForFooterInsection:
से लौटाए गए मान के नकारात्मक के लिए अपने टेबलव्यू के निचले सामग्री इन्सेट को सेट करने की आवश्यकता होगी इस उदाहरण में यह -1*BACKGROUND_IMAGE_HEIGHT*9
होगा। आप इंटरफ़ेस बिल्डर के आकार निरीक्षक से या नीचे tableviewcontroller से self.tableView.contentInset
संपत्ति सेट करके नीचे सामग्री इन्सेट सेट कर सकते हैं।
चीयर्स!
* टक्कर * एक समाधान है कि काम करता है मिल गया? कृपया यहां साझा करें। धन्यवाद – lostInTransit
मैंने अभी तक जो किया है वह तालिका दृश्य के अंत में एक 'अदृश्य' सेल जोड़ता है जिसमें एक छविदृश्य है जो तालिका दृश्य के अंत की छाया प्रदर्शित करता है। मैंने विभाजक शैली को किसी को भी सेट नहीं किया है। यह एक समान प्रभाव बनाता है लेकिन मुझे इसके साथ खुश होने के लिए थोड़ा और ट्विक करना होगा। –