iOS 15 - UITableViewCell accessoryView Frame issue - ios15

I have a custom UIView containing UILabel as cell.accessoryView = containerView. It was working fine until iOS 14 but as of iOS 15, the containerView is changing its frame on tableView reload. It is displaying properly on the first load but reloading causes the accessoryView to change its frame. My code is
let notificationLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
containerView.clipsToBounds = true
containerView.backgroundColor = .clear
containerView.addSubview(notificationLabel!)
cell.accessoryView = containerView
I am changing the frame of the container based on text in UILabel in cellForRowAtIndexPath.
It seems the frame code for containerView is messing up. But this is working fine in iOS 14.
I guess there are some changes and the accessoryView position is allowed to be changed in iOS 15.
Any suggestions to make it work without giving exact x-axis or y-axis in iOS 15?

It's possible what your seeing is the extra "by default" padding added to the section header.
In your Viewdidload add
if (#available(iOS 15.0, *)) {
[self.tableViewName setSectionHeaderTopPadding:0.0f];
}

I could not find a solution for this either. So I gave up on iOS 15's cell.accessoryView.
Instead, my cellForRowAtIndexPath handler calls:
[cell.contentView removeAllSubviews]
[cell.contentView addSubView:myCustomView]

Related

Fabric.js hasControls=false and hasBorders=false but it is still selectable

I was trying to add to canvas item which will be dragable but not selectable so I did like this
var canvas = new fabric.Canvas('root');
canvas.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 }));
canvas.add(new fabric.Circle({ radius: 30, fill: '#5f5', top: 160, left: 100 }));
canvas.item(0).hasControls = canvas.item(0).hasBorders = false;
Now I'm not able to select as a group element 0 (this is ok!) but when I'm selecting group which contains also item 1 then item 0 is also selected (this is not good). How can I fix it?
I know this question is very old but:
canvas.item(0).hasControls = canvas.item(0).hasBorders = false;
Will make the object with invisible border and invisible controls, so it looks like you are not selecting it, but you are still doing and not drawing any controls.
There is no way to make an object unselectable BUT draggable.
If you cannot select it ( setting .selectable=false), you cannot drag it.
When an object is in a selection group its border get drawn anyway, whatever setting is on .hasBorders.

MonoTouch UIButton Gradient Covers Title

I have a similar problem to this post (UIButton: Add gradient layer and title is not shown anymore - how to fix?) but his solution did not work for me. First things first, I'm somewhat new to MonoTouch, but have never gone as far as customizing the out of the box controls.
I am trying to add a gradient to my button, but when I do so, the gradient looks exactly as I want, but the text is covered (I set the opacity of my gradient to .5 to test). I have a storyboard in which I have visually designed the interface, but want to tweak a few things.
Here is my code:
var gradient = new CAGradientLayer();
gradient.Frame = getStartedButton.Layer.Bounds;
gradient.Colors = new MonoTouch.CoreGraphics.CGColor[]
{
UIColor.FromRGB (23, 55, 94).CGColor,
UIColor.FromRGB (33, 81, 141).CGColor
};
getStartedButton.Layer.AddSublayer(gradient);
getStartedButton.Layer.CornerRadius = 10;
getStartedButton.Layer.BorderColor = UIColor.White.CGColor;
getStartedButton.Layer.BorderWidth = 1;
getStartedButton.VerticalAlignment = UIControlContentVerticalAlignment.Center;
getStartedButton.Font = UIFont.FromName("Helvetica", 12);
getStartedButton.SetTitleColor(UIColor.White, UIControlState.Normal);
getStartedButton.SetTitle("Get Started", UIControlState.Normal);
Embarrassing, but it was simply a matter of changing the type of button to custom in XCode.

UIWebView keeps Portrait dimensions when viewed in Landscape

I have been unable to find a solution to this problem anywhere.
I am using Xcode 4.5 to write an iOS 6 app using storyboards. It uses a Navigation Controller to jump between several View Controllers with Navigation Bars, including a few that use a UIWebView to display a website. I have added code to the AppDelegate and various ViewController files to restrict the view to Portrait for most scenes in the app (since they really won't look good otherwise), but to allow Landscape view for the websites. And the Info.plist is configured allow all 4 orientations.
Everything works fine in the UIWebView scene; including rotation, scrolling and zooming - except for one thing: when I rotate from Portrait to Landscape, the horizontal dimension of the website stays locked at the horizontal dimension for the Portrait view - resulting in a large white space to the right of the website in the scene (see images below). I fixed a small (1/4") white space at the top of the UIWebView by selecting Layout: Wants Full Screen under View Controller in the Attributes Inspector. But I can't fix this.
I can supply relevant code or Storyboard settings if necessary. Can anyone help? Thank you.
I solved adding this code, when application loads on viewDidLoad method:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:#selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
Then add this to your view controller:
- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationPortrait:
_displayWeb.frame = CGRectMake (0, 0, 768, 1024);
break;
case UIDeviceOrientationPortraitUpsideDown:
_displayWeb.frame = CGRectMake (0, 0, 768, 1024);
break;
case UIDeviceOrientationLandscapeLeft:
_displayWeb.frame = CGRectMake (0, 0, 1024, 768);
break;
case UIDeviceOrientationLandscapeRight:
_displayWeb.frame = CGRectMake (0, 0, 1024, 768);
break;
default:
break;
};
}
_displayWeb is your IBOutlet UIWebView, by the way this is using Xcode 4.6.1

iOS 5 SDK UITextView limitation / bug?

I have a UITextView with a lot of text in it. When the subview containing the UITextView is shown the UITextView only appears after the UITextView has been touched and scrolled.
Is there a limit of how much text can be in a UITextView?
Or is this a bug?
attached is a clip explaining this occurrence.
https://dl.dropbox.com/u/8256776/UITextView%20Bug.MOV
Ok, I have looked into it and it seems to be quite a common issue. It seems that the text view doesn't feel that it has to draw the text, but calling setNeedsDisplay doesn't help. I don't know if there is a "real" solution, but you can force it to draw the text by scrolling programmatically:
disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);
An unrelated thing in your code: In your switchView method you have two animations, one for the menu view and one for the view you are sliding into place. This is unnecessary as you can put both setFrame calls in the same animation:
MenuView = (UIView *)[self.view viewWithTag:100];
appView = (UIView *)[self.view viewWithTag:ViewInt];
[MenuView setFrame:CGRectMake(0, 0, 320, 480)];
[appView setFrame:CGRectMake(321, 0, 320, 480)];
[UIView beginAnimations:#"move buttons" context:nil];
[UIView setAnimationDuration:.5];
[MenuView setFrame:CGRectMake(-320, 0, 320, 480)];
[appView setFrame:CGRectMake(0, 0, 320, 480)];
disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);
[UIView commitAnimations];
And one more thing (and then I will back off :) )
You seem to be quite fond of using tags to retrieve elements. While it does work, it is not very understandable. You don't have that many elements so I would just add each of them as IBOutlet with a meaningful name (like you did with your disclaimerView). Also, have seperate switchView methods for the different views you are moving into place. That way you can easily perform additional stuff you might need for just that view, like the force scroll on disclaimerView.

Incorrect y position for objects inside UIViewController's view

I created programmatically a multi view iphone application.
when adding objects to a view, like a button for example. in position x = 0, y = 0
this results to x = 0, y = 20 in the iphone simulator.
this is the used code :
UIButton *btnGoToStartView = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnGoToStartView.frame = CGRectMake(0, 0, 240, 30);
[btnGoToStartView setTitle:#"Btn Name" forState:UIControlStateNormal];
[btnGoToStartView addTarget:self action:#selector(myBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnGoToStartView];
In the other hand, when I'm placing a button using Interface Builder in position x = 0, y = 0 the result is good.
Till now I didn't found the real reason for this vertical shifting.
Thanks in advance for your hints.
Regards.
It's Ok, I found the solution.
It's a problem of the UIView not the control.
in Interface builder, I opened the MainWindow.xib then I modified the attribute Layout in the inspector window.
I checked [wants full screen].
That's all.

Resources