I made a popover containing sectioned tableView with some background. I want to remove that thin vertical border line, which is present on sides between two sections.
set view's background color or image to your custom color/image then and set tableview's background to nil. It should work.
- (void)viewDidLoad
{
[super viewDidLoad];
//background image
self.view.backgroundColor= [UIColor clearColor];
self.view.backgroundColor=[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"yourimage.png"]];
//table background image, mytableview should be your tableView's name you can try self.tableView if you have not set/delegate anything to it.
self.mytableView.backgroundView = nil;
}
Related
I'm having an issue receiving touches in UICollectionViews contained within UITableViewCells. The desired effect is a UITableView with n rows of horizontally scrolling UICollectionViews. The view is displaying correctly but the collection views only receive touches in the top 44px. I imagine that the table view is still in the process of initialization when the collection views are created and that the collection views are using UITableView's default cell height when setting up their gesture recognizers. Relevant code is below.
In my UITableViewCell subclass, I create a container view for the UICollectionView:
- (void)layoutSubviews
{
if (!_collectionViewContainer) {
_collectionViewContainer = [[CVTCollectionViewContainer alloc] init];
_collectionViewContainer.frame = self.bounds;
[self.contentView addSubview:_collectionViewContainer];
};
}
In my container view, I instantiate a UICollectionView:
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if (!self.collectionView) {
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.backgroundColor = [UIColor clearColor];
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flowLayout.itemSize = CGSizeMake(130.0, 130.0);
[_collectionView registerClass:[CVTCollectionViewCell class] forCellWithReuseIdentifier:#"Collection view cell"];
[self addSubview:self.collectionView];
}
}
There's nothing interesting in my UITableViewController, just that I return 200 in tableView:heightForRowAtIndexPath:
It occurred to me that the layoutSubviews method of my UITableViewCell subclass may be the wrong place for initialization of the 'container' view for my UICollectionView. But, when I NSLog(#"cell: %#", self); in layoutSubviews, the cell's frame shows the desired height (200). Still, I have a feeling that I am doing my setup for the collection view too early, but I can't think of where else I might perform this work.
So, the gist: how can I add a UICollectionView to a UITableViewCell and make sure that the UICollectionView's gesture recognizers respond in the entirety of the collection view, rather than just the top 44 px?
Thanks in advance, as always.
Bit of a facepalm here, I was using a UITableViewController that was created in storyboard but mostly configured in code. In storyboard, I had not set the row height of the table view, so it was still at the default 44 px. Of course, the table view looked at IB for its initial config so, although tableView:heightForRowAtIndexPath: was being called and the cells were displaying correctly, the initial height set in IB was affecting how the cell's subviews were created.
I want change color of this view. I want tabbar more button view color same as app color,not white. how it is possible.
Fo this you have to customize moreNavigationController. One solution is to subclass your UITabBarController and add following on - (void)viewDidLoad method.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UINavigationController *moreController = self.moreNavigationController;
//if u want to custamize navigationBar u can customize
//moreController.navigationBar
if ([moreController.topViewController.view isKindOfClass:[UITableView class]]) {
//Custamize your tableview here
UITableView *tableView = (UITableView *)moreController.topViewController.view;
//Change the color of tableView
[tableView setBackgroundColor:[UIColor redColor]];
moreController.topViewController.view = tableView;
}
}
I hope this helps you
to customize the tabBarItem you can follow other answers.
I have grouped table view. I want to add UISegmentedControl in table cell with clear background so that it will be displayed as FOOTER . How can I do this? I tried using clearColor. But it's not working.
Set the background view with a clear UIView object like so:
UIView *clearView = [[UIView alloc] initWithFrame:CGRectZero];
[clearView setBackgroundColor:[UIColor clearColor]];
[self setBackgroundView:clearView];
[clearView release];
And make sure you set cell selection style to none.
Edit: added some square brackets
When I receive a memory warning in my navigation based iPhone App the background image disappears in the previously allocated navigation controllers.
The background image is set as the background property of a UIView. This view is then added to the main window of the App delegate:
UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[[Utilities sharedManager] getImageWithName:#"Hintergrund2"]];
backgroundView.tag = 56789;
[window addSubview:backgroundView];
[backgroundView release];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
After I received the memory warning message and pressed the back button of the navigation controller the previous navigation controller shows up the normal Apple gray background. I have to navigate back to my home screen and navigate forward to "reset" the background image.
Can anyone tell me why the background disappears? It is not because of the image, when I set the background to a standard UIColor like blackColor the background (color) also disappears.
Thank you in advance for your help!
regards
Phil
It is undefined what the OS does with stuff added directly to the main UIWindow in case of low memory situations.
Maybe consider using a simple UIViewController for the background? You will then at least get callbacks when there is a low memory situation.
First, you should probably add your controller to the window like this:
window.rootViewController = navigationController;
I haven't tested this, but perhaps you can set the background color of the window directly:
window.backgroundColor = [UIColor colorWithPatternImage:[[Utilities sharedManager] getImageWithName:#"Hintergrund2"]];
If that doesn't work, you'll need a better way to recreate your view state in low memory situations. The most standard way to do this is by defining the background in each xib, which is reloaded. Alternatively, you could catch the low memory warning and recreate as needed by seeing if your backgroundView has a superview.
Make sure that you are setting the calling self.view.backgroundColor = [UIColor clearColor]; in the view controller's - (void) viewDidLoad otherwise the window's image will not be displayed.
- (void) viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
...
}
My problem was that I set the view's backgroundColor when it is initialized
MyTableViewController *myTVC =
[[MyTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
myTVC.view.backgroundColor = [UIColor clearColor];
and not in - (void) viewDidLoad.
In this situation, the UITableViewController's view's background color was set after it was initially created. However after a low memory warning, the UIViewController's that were not displayed have - (void) viewDidUnload called on them. That deallocate their views. Just before the UIViewController was to be displayed again, - (void) viewDidLoad was called and created a new view, but the view's background color was set to the default which is not clear.
Iam creating a custom TableView Cell Which has some text and a Background image. when i select the cell then the image should chnage but this is not hapening, i have use following code so some one help me?
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if (selected)
[self.imgSelected setImage:[UIImage imageNamed:#"listing-gradient-hover.png"]];//Image that i want on Selection
else
[self.imgSelected setImage:[UIImage imageNamed:#"listing-gradient.png"]];
//Normal image at background everytime table loads.
// Configure the view for the selected state
}
This is not working for me.
Try the following:
initialize an UIImageView to be the background view and an UIImageView to be the selected background view when you setup ypu custom table view cell:
self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"listing-gradient-hover.png"]];
self.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"listing-gradient.png"]];
UITableViewCell adds the value of the selectedBackgroundView property as a subview only when the cell is selected. It adds the selected background view as a subview directly above the background view (backgroundView) if it is not nil, or behind all other views. Calling setSelected:animated: causes the selected background view to animate in and out with an alpha fade. You do not need to override this method just for switching the background image upon selection.