gpt4 book ai didi

objective-c - 删除分组的 UITableView 中的顶部阴影?

转载 作者:搜寻专家 更新时间:2023-10-30 19:55:34 25 4
gpt4 key购买 nike

我有点强制症,这让我发疯。我已经弄乱这些设置很长时间了。

我有一个 UITableView 分组,顶部有一个阴影。当您点击顶部的单元格时,它会移除。给了什么?

在过去的一个多小时里,我一直在为此强调。有一个简单的解决方案吗?还是我要疯了?

谢谢,库尔顿

enter image description here

编辑:

viewDidLoad:

formTableView.backgroundColor = [UIColor clearColor];
formTableView.layer.borderColor = [UIColor clearColor].CGColor;
formTableView.separatorColor = [UIColor colorWithRed:(194.0 / 255.0) green:(194.0 / 255.0) blue:(194.0 / 255.0) alpha: 1];

这是我显示单元格的方式。 警告:这是很多代码。里面有一堆东西你必须整理,所以整理它需要你自担风险! :)

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}


- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}

// What to do when you click delete.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}

//RootViewController.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

if (section == 0) {
return [formDataOne count];
} else {
return [formDataTwo count];
}
}

//RootViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {



static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}

// Set up the cell...
NSString *cellValue;
if (indexPath.section == 0) {
cellValue = [formDataOne objectAtIndex:indexPath.row];
} else {
cellValue = [formDataTwo objectAtIndex:indexPath.row];
}


if (indexPath.section == 0) {
cell.text = @"";
cell.selectionStyle = UITableViewCellSelectionStyleNone;

if (indexPath.row == 0) {
addTitle = [[UITextField alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
addTitle.borderStyle = UITextBorderStyleNone;
addTitle.textColor = [UIColor blackColor]; //text color
addTitle.font = [UIFont systemFontOfSize:16.0]; //font size
addTitle.placeholder = @"Album Name"; //place holder
addTitle.backgroundColor = [UIColor clearColor]; //background color
addTitle.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
addTitle.keyboardType = UIKeyboardTypeDefault; // type of the keyboard
addTitle.returnKeyType = UIReturnKeyDone; // type of the return key
addTitle.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
addTitle.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
[cell.contentView addSubview:addTitle];
} else if (indexPath.row == 1) {
// Set up loading text and show it
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
myLabel.text = @"Private Album";
myLabel.textColor = [UIColor blackColor];
myLabel.textAlignment = UITextAlignmentLeft;
myLabel.backgroundColor = [UIColor clearColor];
myLabel.font = [UIFont fontWithName:@"Helvetica" size: 16.0];
myLabel.numberOfLines = 0;
//[myLabel sizeToFit];


privateSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[privateSwitch addTarget:self action:@selector(switchToggled:) forControlEvents: UIControlEventTouchUpInside];
[cell.contentView addSubview:privateSwitch];
//[privateSwitch setOn:NO animated:NO];

if ([howToDisplay isEqualToString:@"no"]) {
[privateSwitch setOn:NO animated:NO];
} else {
[privateSwitch setOn:YES animated:NO];
}



[cell.contentView addSubview:myLabel];
} else {
// Set up loading text and show it
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, 13, 280, 20)];
myLabel.text = @"Comments";
myLabel.textColor = [UIColor blackColor];
myLabel.textAlignment = UITextAlignmentLeft;
myLabel.backgroundColor = [UIColor clearColor];
myLabel.font = [UIFont fontWithName:@"Helvetica" size: 16.0];
myLabel.numberOfLines = 0;
//[myLabel sizeToFit];
[cell.contentView addSubview:myLabel];

commentsSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:commentsSwitch];
[commentsSwitch setOn:YES animated:NO];
}

} else {
//cell.text = cellValue;

UILabel *labelOne = [[UILabel alloc] initWithFrame:CGRectMake(48, 12, 130, 20)];
labelOne.text = cellValue;
labelOne.textColor = [UIColor blackColor];
[labelOne setFont:[UIFont boldSystemFontOfSize:16]];
labelOne.textAlignment = UITextAlignmentLeft;
labelOne.backgroundColor = [UIColor clearColor];
//labelOne.font = [UIFont fontWithName:@"Helvetica"];
labelOne.numberOfLines = 0;
[cell.contentView addSubview:labelOne];



if (indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else if (indexPath.row == 1) {
int countFacebook = [dataCeter.connectionFacebookArray count];
if (countFacebook == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else if (indexPath.row == 2) {

//} else if (indexPath.row == 3) {

} else if (indexPath.row == 3) {
int countTumblr = [dataCeter.connectionTumblrArray count];
if (countTumblr == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else if (indexPath.row == 4) {

} else if (indexPath.row == 5) {

} else {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}

}

// Set imageView with correct thumbnail
UIImage *theImage;
if ([cellValue isEqualToString:@"Facebook"]) {

theImage = [UIImage imageNamed:@"icon_small_facebook.png"];
int countFacebook = [dataCeter.connectionFacebookArray count];
NSLog(@"facebook? %d // %@", countFacebook, dataCeter.connectionFacebookArray);

if (countFacebook != 0) {
facebookSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:facebookSwitch];
[facebookSwitch setOn:YES animated:NO];
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

} else if ([cellValue isEqualToString:@"Twitter"]) {

theImage = [UIImage imageNamed:@"icon_small_twitter.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

} else if ([cellValue isEqualToString:@"Flickr"]) {

theImage = [UIImage imageNamed:@"icon_small_flickr.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

} else if ([cellValue isEqualToString:@"Tumblr"]) {

theImage = [UIImage imageNamed:@"icon_small_tumblr.png"];
int countTumblr = [dataCeter.connectionTumblrArray count];

if (countTumblr != 0) {
tumblrSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:tumblrSwitch];
[tumblrSwitch setOn:YES animated:NO];
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

} else if ([cellValue isEqualToString:@"Email"]) {

theImage = [UIImage imageNamed:@"icon_small_email.png"];
int countEmail = [dataCeter.connectionEmailArray count];

} else if ([cellValue isEqualToString:@"MMS"]) {

theImage = [UIImage imageNamed:@"icon_small_mms.png"];
int countMMS = [dataCeter.connectionSMSArray count];

} else if ([cellValue isEqualToString:@"Photostream"]) {

theImage = [UIImage imageNamed:@"icon_small_photostream.png"];
cell.accessoryType = UITableViewCellAccessoryNone;
photostreamSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[cell.contentView addSubview:photostreamSwitch];
[photostreamSwitch setOn:YES animated:NO];

} else {

theImage = nil;
cell.accessoryType = UITableViewCellAccessoryNone;

}
cell.imageView.image = theImage;

return cell;
}

最佳答案

将表格 View 的分隔符样式设置为 UITableViewCellSeparatorStyleSingleLine。它目前被设置为 UITableViewCellSeparatorStyleSingleLineEtched,这在 iPhone 上产生了双顶边框的效果(它在 iOS 5 以及 iPad 上的 iOS 3.2 和 4 上看起来更详细)。

关于objective-c - 删除分组的 UITableView 中的顶部阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6171489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com