When using the iOS 6 SDK and running my app in the iPhone 5.0 simulator my tableview appears just fine as a grouped style tableview. However when I run my in the iPhone 6.0 simulator it appears as a UITableViewStylePlain tableview.
Any ideas what would cause this strange behavior? I'm not doing anything too crazy in the tableview besides a textview inside a tableview cell.
I have a grouped tableview that is working correctly in iOS6 using the code:
tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.bounds.size.width,self.bounds.size.height) style:UITableViewStyleGrouped];
[tableView setDataSource:self];
[tableView setDelegate:self];
Are you using the Interface builder to create this grouped tableview or are you creating it programmatically? There seems to be quite a few issues with iOS6 and previously created interfacebuilder views.
If you are using the IB to create things can you try to re-create the tableview in code (redundant and useless, I know, but it may show what is the problem).
Somewhere in your viewDidLoad() function put
if(tableView)
{
[tableView removeFromSuperview];
}
tableView = [[UITableView alloc] initWithFrame:tableView.frame style:UITableViewStyleGrouped];
[tableView setDataSource:self];
[tableView setDelegate:self];
[self addSubview:tableView];
This may be poor coding or cause memory leaks if not using arc, but it would be interesting to see if you get a grouped styling that way.
This code solved the ios6 grouped tableview problem for me:
tableView.backgroundColor = [UIColor clearColor];
tableView.opaque = NO;
tableView.backgroundView = nil;
Related
In my project, I have a UITableView with different types of cells.
One of these cells contains a horizontally scrolling UICollectionView.
When I run my project, the UICollectionView is correctly populated, but I cannot scroll horizontally, clicking and dragging inside this UICollectionView only allows for me to scroll the tableview vertically.
The desired behaviour would be that a click inside the cell with the UICollectionView would allow the user to scroll horizontally, clicking in any other cell allows for vertical scrolling.
I'm assuming that I need to overwrite/pass on or disable some OnClick event in this cell however I cannot find the correct solution.
Any help pointing me in the good direction would be greatly appreciated :)
The code for creating the concerning TableViewCell looks like this.
#property(nonatomic) HorizontalCollectionViewDelegate *horizontalCollectionViewDelegate;
- (UITableViewCell *) createHorizontalScrollCell:(NSIndexPath *)indexPath tableView:(UITableView *)tableView{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myCellIdentifier];
MyHorizontalScrollingTableCell *myHorizontalScrollingTableCell = (MyHorizontalScrollingTableCell *)cell;
UICollectionView *horizontalCollectionView = myHorizontalScrollingTableCell.myHorizontalCollectionView;
//Link collectionView to its delegate
self.horizontalCollectionViewDelegate = [[HorizontalCollectionViewDelegate alloc] init];
horizontalCollectionView.delegate = _horizontalCollectionViewDelegate;
horizontalCollectionView.dataSource = _horizontalCollectionViewDelegate;
_horizontalCollectionViewDelegate.data = myData;
//Define the cells in HorizontalCollectionView
UINib *cellNib = [UINib nibWithNibName:#"CollectionViewCell" bundle:nil];
[horizontalCollectionView registerNib:cellNib forCellWithReuseIdentifier:#"horizCell"];
//Define flow of AttachmentsCollectionView
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(90, 90)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[horizontalCollectionView setCollectionViewLayout:flowLayout];
return cell;
}
EDIT: I'm using the same HorizontalCollectionViewDelegate elsewhere in my project (just not in a tableview) and over there it is working, so I assume the problem is not there.
EDIT 2: Problem solved, turns out there wasn't a problem (see answer below), will be accepting my answer in two days when I can.
Solved...
Turned out I only needed to add more content to the UICollectionView.
With 2 or 3 elements the Cells did not fill the complete view. Because the swipe animation was not showing I assumed there was an error somewhere.
However just adding more content solved this issue.
In a prior Xcode versions, settings the separator style to none for the UITableView via the interface builder used to solve the problem.
But, this is no longer works in Xcode 7. How to remove/hide the UITableView Seperator in Xcode 7?
Xcode 7 is no longer picking the separator style from the interface
builder. This may also be related to the iOS 9 SDK as the Base SDK.
But, it always can be achieved programmatically:
// objective-c
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
// swift
tableview.separatorStyle = .None
Related, this is also applied on the UITableView background color:
// objective-c
[tableView setBackgroundColor:[UIColor clearColor]];
// swift
tableView.backgroundColor = .clear
In table init (viewDidLoad) you can adding this line:
self.tableView.separatorColor = [UIColor clearColor];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
I have one problem regarding UITableview running with Xcode 6.1 + iOS SDK 8.1.
I have one simple single view application, something strange happened when i was using storyboard to create a tableview.
Inside of my viewDidLoad, I wrote this code:
UITableView *tableView = (id)[self.view viewWithTag:1];
[tableView registerClass:[NameAndColorCell class] forCellReuseIdentifier:CellIdentifier];
added/edited:
UITableView *tableView = (id)[self.view viewWithTag:1];
NSLog(#"Table View Tag = %ld", (long)tableView.tag);
[tableView registerClass:[NameAndColorCell class] forCellReuseIdentifier:CellIdentifier];
UIEdgeInsets contentInset = tableView.contentInset;
contentInset.top = 20;
[tableView setContentInset:contentInset];
But the tableView is always nil, and eventually caused my App crashed.
I checked with my View Controller's View, both "Use Auto Layout" and "Use Size Classes" were enabled.
After I disabled "Use Size Classes", everything went back normal. I mean, tableView was created successfully.
Has anyone met the same issue? Is this a bug from Xcode? or I made some mistake?
Please help me, Thanks a lot !
Best Regards,
Rui
I am having a problem in displaying cell separator of grouped style tableView in iOS 7.
if ([projectTable respondsToSelector:#selector(setSeparatorInset:)]) {
[projectTable setSeparatorInset:UIEdgeInsetsZero];
projectTable.separatorColor = [UIColor blackColor];
}
This doesn't show cell separator. Kindly suggest
In iOS7 design. try to do the below:
[projectTable setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
and also you have to do:
[projectTable setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
You can set the 'Separator Inset' from the nib or Storyboard:
Even though it has a default value (UITableViewCellSeparatorStyleSingleLine), have you tried reseting your separatorStyle property ?
[projectTable setSeparatorStyle:UITableViewCellSeparatorStyleSingleLineEtched];
I have a UItableview in my IOS app with some information in it. I changed the Selected background color to clearcolor using the following code:
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor clearColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];
There is text and 2 images in the cell, I've build this using CGRectMake.
But When I select and hold a table cell the the images disappear behind what looks like a white background.
As you can see I'm holding the "Dacnusa sibrica" cell, how can I fix this?
If you want to disable the blue selection of cells you can also set the cell's selection mode instead of modifying the background:
cell.selectionStyle = UITableViewCellSelectionStyleNone
This simply disables the blue selection when tapping the cell but still allows the cell to be selected (and thus handled by code).
With Auto layout it is possible to define Selection=None (default is gray) in the Interface Builder.
have you used [cell.contentView addSubview:image]?
use [tableView deselectRowAtIndexPath:indexPath animated:YES];
for deselecting the cell