I use InAppSettingsKit in my projects. And everything was good befor iOS 9 update. I hadn't this problem in iOS 8. It still work but now cell alignment looks strange. Now cell content has strange offset from the left and right sides.
I've downloaded the sample project and found interesting moment. And edited one cell configuration cell. So in fact cell is green, contentView is red.
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kIASKPSToggleSwitchSpecifier];
cell.accessoryView = [[IASKSwitch alloc] initWithFrame:CGRectMake(0, 0, 79, 27)];
cell.contentView.autoresizingMask |= UIViewAutoresizingFlexibleWidth;
cell.contentView.backgroundColor = [UIColor redColor];
cell.backgroundColor = [UIColor greenColor];
[((IASKSwitch*)cell.accessoryView) addTarget:self action:#selector(toggledValue:) forControlEvents:UIControlEventValueChanged];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
When controller configuring form xib it works good.
Configuration:
Result:
So... Normal left and right offsets. Have no any problems. But! after programmatically push.
- (IBAction)showSettingsPush:(id)sender {
[self.navigationController pushViewController:[[IASKAppSettingsViewController alloc] init] animated:YES];
}
I have this strange result(The same problem in my app):
InAppSettingsKit Source
P.S. Any way thanks for your attention. I would be grateful for any help.
This is actually an iOS 9 feature (cellLayoutMarginsFollowReadableWidth) that limits cells to a good readable width. And IMO your second screenshot looks better. (On a sidenote: in your first shot the section titles are incorrectly aligned - not sure what's the reason for this, works fine in the sample app here).
There's a pull request that allows you to disable this property (default is YES): https://github.com/futuretap/InAppSettingsKit/pull/317
I'll look into potential side effects and might merge this at some time.
Related
I have the following code in my willDisplayCell function
//bottom border
UIView* bottomBorderView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height-1, cell.frame.size.width, 1)];/// change size as you need.
bottomBorderView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"dot.png"]];// you can also put image here
[cell.contentView addSubview:bottomBorderView];
It worked just fine in iOS7, but ever since I updated Xcode and started testing the app on iOS8 the borders have been displaying incorrectly. I cant figure out what changed that is causing the issue. The problem seems to get worse the more you scroll.
I have set cell.accessoryView and another image. But accessoryView is always on top. Is there a way to send this to the back? I've tried:
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:#"arrow-right.png"]];
[cell sendSubviewToBack:cell.accessoryView];
Any ideas? I guess I could just create a separate image, instead of using accessoryView, but wondering if there's an easier way.
Here's what it looks like:
I found a good solution for you ...
when you want to hide it from the cell ... you can't send it to back because the cell views are arranged by Apple defaults ...
but u can hide it by setting the accessoryView to a Fake Image (I meant image that's not found in the disk) ...
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Fake.png"]];
I hope that helps anyone...
I am using EasyTableView Library, Can you please tell me , When I am dynamically creating rows for my Tableview, why it is showing so much performance lag in the Instruments?
The Code in the above image is as follows:
CGRect buttonRect = CGRectMake(10, 0, 473, 677);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = buttonRect;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, button.frame.size.height-100, button.frame.size.width,50)];
label.backgroundColor = [UIColor blackColor];
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
[button addSubview:label];
// Use a different color for the two different examples
return button;
It looks like you're regenerating a cell view for every cell (i.e. never reusing the views).
Looking at the docs for EasyTableView, it looks like ETV does NOT incorporate a view caching mechanism, so it's generating new views for every row of the tableview.
And if your tableview has dozens or hundreds of rows, you are in deep trouble. I suggest getting rid of EasyTableView and using UITableViews that have cell view caching and reuse.
Alternatively, implement your own view caching and reuse. So in your case you'd have a pool of UIButtons, and every time you need to return a UIButton in easyTableView:viewForRect:, check if there's one that isn't currently visible on screen. If so, reuse it and change whatever you need (label text, etc...). Otherwise, create a new one.
It's impossible to tell if you have any performance issues based on that screenshot, all there is that button takes 34% of time inside viewForRect, which is probably tiny. To get better picture open right sidebar in Instruments and see where time goes, or show your call trace with timing, not the code view.
Now, in general, creating cell views is not a bottleneck, but not reusing them in UITableView is.
So, this title probably makes me look new and like I haven't looked for answers here, so first, let me state that: I did already check for answers on setting the background to transparent, as well as selection to custom (also not working).
My point: I created a custom table view cell, set everything to transparent, but nothing was transparent.
So I looked here, looped through all the subviews, their subviews, and the cell.backgroundColor and set it to transparent.
I implement the -(tableView*)willDisplayCell method and did the recommended steps, still not transparent.
I messed with the setSelected: callback method, doing the recommended along with setting the subviews to transparent.
Now I must thank Apple for a white background.
So I eventually just plugged in an image view with a similar color. I would prefer not to use that method.
I set the type to a custom table view cell, (in the Xib, I chose "Custom" in the drop down on the main view properties on the right).
Here's my code:
[code] (sorry about formatting, StackOverflow says the tab key will do it... in a browser...)
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"TheCustomTableViewCellTableViewCell" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
// Load the top-level objects from the custom cell XIB.
TheCustomTableViewCell * customCell = (TheCustomTableViewCell*)cell;
customCell.titleTextLabel.text = item.title;
//This is Matt Gallagher 's answer modified but isn't working
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor redColor];
[/code]
Final note, I've tried hooking up different views inside my Xib as "The backgroundView" and setting those to transparent, as well as create my own, curious if there's a specific way I have to do that to get it to finally be transparent.
I have a feeling recursively looping through every single view is not the best solution, and probably wouldn't work.
It could just be I need to reboot the computer, but I've already cleaned the build and restarted XCode 4.
Any help would be greatly appreciated... I'm in Xcode 4 iOS 5, the one that makes having dual monitors pointless by stripping all your edit functions out of the Xib editor if you try to edit it in the other window! Just to be specific. Also, the install is fresh, I don't have the iOS 4 emulator, will grab it soon and see if it's version issues
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Background.png"]];
...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor clearColor];
...
}
For group table cell, I fall into this problem.
cell.backgroundColor=[UIColor clearColor]
make the cell bg black. It works for normal cell, not for group table cell.
I want to add some button, e.g. like the detail view of iPhone contact with transparent background.
If anybody face the problem, I got a solution, set a transparent view as a background view of the cell. Then it becomes totally transparent. Then you can add more view or customize the cell.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
messageCell.backgroundView = backView;
messageCell.contentView.layer.cornerRadius = 10.0;
messageCell.contentView.layer.borderWidth = 1.0f;
messageCell.contentView.layer.borderColor = [[Settings getInstance] colorFrameBorder].CGColor;
messageCell.selectionStyle = UITableViewCellSelectionStyleNone;
return messageCell;
This solution was quoted in one of the StackOverflow question, which I cant remember.
I have also found that, its easy to add a transparent view in the table header or footer. The button down the contact details are probably added in a footer view.
From the looks of it I'd say you are setting a background image to your cell. You can see it at each cell on the right side, there are the stripes from your view background.
Remove the cell's background and you should be fine.
I found the solution from this answer here by setting cell's backgroundView
cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
I would take Charles's answer one step further and do the following
self.myTableView.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];