यह एक आसान समस्या की तरह लगता है, लेकिन मैं एक ईंट की दीवार पर पहुंच जाते हैं एक समाधान खोजने और मैं आशा करती हूं यहां पर किसी की मदद कर सकते हैं ...1 पिक्सेल की खाई
मैं एक UITableView UITableViewStyleGrouped का उपयोग कर बनाने रहा हूँ, और मैं एक छोटे से (1 पिक्सेल) सफेद मेरी तालिका दृश्य के हर खंड की पहली और दूसरी पंक्ति के बीच की रेखा दिखाई दे रहा है (छवि देखें)
ऐसा लगता है कि कारण इस पंक्ति के लिए यह है कि प्रत्येक खंड में पहला कक्ष दूसरों की तुलना में 1 पिक्सेल लंबा है। जब मैं प्रत्येक समूह का प्रारंभिक कक्ष 2 9 पिक्सेल ऊंचा (अन्य 30) होता हूं तो अंतराल गायब हो जाता है और सब ठीक है।
हालांकि यह कामकाज सफल है, लेकिन मैं इसके होने का कारण जानना चाहता हूं इसलिए मैं एक गन्दा हैक का उपयोग करने से बच सकता हूं।
FYI करें:
- मैं का उपयोग करके यकीन है कि यह मेरे पास है पृष्ठभूमि छवियों के साथ कोई समस्या नहीं है बना दिया है - वे सभी 30px उच्च रहे हैं, और मैं एक ही साथ एक मध्यम छवि के साथ शीर्ष छवि जगह ले ली है परिणाम।
- मैं separatorStyle = UITableViewCellSeparatorStyleNone
- इस आशय की स्थापना द्वारा कोशिकाओं के बीच सभी सीमाओं को हटा दिया है UITableViewStylePlain
किसी भी मदद की बहुत सराहना कर रहा है पर नहीं होता है।
धन्यवाद
तालिका सेटअप के लिए कोड:
myTable = [[UITableView alloc] initWithFrame:CGRectMake(TABLE_SHIFT_OFFSET,
DATE_SLIDER_HEIGHT - DATE_SLIDER_SHADOW_HEIGHT,
326,
self.view.frame.size.height - DATE_SLIDER_HEIGHT + DATE_SLIDER_SHADOW_HEIGHT) style:UITableViewStyleGrouped];
myTable.backgroundColor = [UIColor clearColor];
myTable.backgroundView = nil;
myTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:myTable];
myTable.dataSource = self;
myTable.delegate = self;
सेल सेटअप के लिए कोड:
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// This is a hack to make sure that a white line doesnt appear between the
// first and second rows in the table, which happens for reasons I dont understand
if (indexPath.row == 0) {
return 29;
}
return 30;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"satCell"];
if (!cell)
{
cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"satCell"];
}
cell.backgroundView = nil;
cell.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
cell.backgroundColor = [UIColor whiteColor];
int numberOfRowsInThisSection = [self tableView:tableView numberOfRowsInSection:indexPath.section];
if (numberOfRowsInThisSection == 1)
{
cell.backingImage = self.singleWhite;
}
else if (indexPath.row == 0)
{
cell.backingImage = self.topWhite;
}
else if (indexPath.row % 2 == 0)
{
// Even row
if (indexPath.row == numberOfRowsInThisSection - 1)
{
// Last row (even)
cell.backingImage = self.botWhite;
}
else
{
// Normal row (even)
cell.backingImage = self.midWhite;
}
}
else if (indexPath.row % 2 == 1)
{
// Odd row
if (indexPath.row == numberOfRowsInThisSection - 1)
{
// Last row (even)
cell.backingImage = self.botDark;
}
else
{
// Normal row (odd)
cell.backingImage = self.midDark;
}
}
// Setup cell text [REMOVED FOR BREVITY]
return cell;
}
MyTableViewCell भीतर समर्थन छवि स्थापित करने के लिए कोड:
- (void)setBackingImage:(UIImage *)backingImage
{
if (self.backingImage != backingImage)
{
_backingImage = nil;
_backingImage = backingImage;
self.backingView.image = backingImage;
}
}
self.backingView निम्न कोड का उपयोग करके स्थापित किया गया है:
[[UIImageView alloc] initWithFrame:CGRectMake(7, 0, 307, 30)];
क्या हम कुछ कोड देख सकते हैं? क्या आपके पास ऊंचाई पर कुछ भी चल रहा है ForRowAtIndexPath :? –
सेल दृश्य संबंधित कोड अच्छा होगा। सेल में किस दृश्य में आप विचार जोड़ रहे हैं, सेल स्वयं, सामग्री दृश्य या पृष्ठभूमि दृश्य? आप अपनी खुद की छवियों को जोड़ रहे हैं जिसमें सीमा है? मैंने कुछ परीक्षण किए और मुझे लगता है कि विभाजक शैली समूहबद्ध तालिकाओं के साथ काम नहीं करती है, वे हमेशा विभाजक को आकर्षित करते हैं। –
मैंने उन सभी कोड को जोड़ा है जिन्हें मैं सोच सकता हूं जो तालिका संरचना को प्रभावित कर सकते हैं। यदि आवश्यक हो तो मुझे कुछ और जोड़ने में खुशी होगी ... पीएस। ऊंचाई में हैक ForRowAtIndexPath: मेरा वर्तमान कामकाज है। यदि हैक हटा दिया गया है, तो अंतर – sleeke