Swift 5 Migration has Change Circular Images - image

I have a table view controller with many table view sections. In each table view section, there is a table view cell. In each table view cell, there is a content view. In each content view, there is some text and an imageView. The image view is a round profile picture with border. It has always worked. This is the code for each image view:
self.imageView1.layer.cornerRadius = self.imageView1.frame.size.width / 2;
self.imageView1.clipsToBounds = true;
self.imageView1.layer.borderWidth = 2.0
self.imageView1.layer.borderColor = UIColor.white.cgColor
I just migrated to Swift 5, and the circles are now square. No coding changes have been made whatsoever. In fact, when I migrated, the changes that it showed that it would make shouldn't have interfered at all with the roundness of the image.
I am at an utter loss as to how to correct it.

Well, nothing suggested here or at Apple developer forums worked. I racked my brain for days...nothing. Finally gave up and decided to just remove it from the next version of the app. While doing this, I decided to try one more thing and it worked. In this line of code:
self.imageView1.frame.size.width / 2;
I started making the number 2 a smaller number. When I got to 0.6 the image was perfectly round again. I have no idea why everything worked perfectly using 2 before the Swift 5 migration...nothing was chnaged. I am just glad I finally got it to work. Thanks to all for your suggestions.

Related

Keeping pagination and screen sizes

I am using the laravel documentation code and have pagination showing through
{!!$sights->appends(Request::all())->links()!!}
The problem i encounter is that i have six pages and that is fine showing all six links with a next and previous button on desktop but when i change the screen size to mobile it is too big and goes down to a second line, how do i get the pagination to fit the screen. Does it respond to CSS or is their php i need to add?
If you are using jQuery, you can do this.
$('.pagination').addClass('pagination-sm')
By your above code, it will generate pagination class, which is actually work for medium screen. You can also add pagination-lg class.
Hope this help :)

Swift 2 SpriteKit issues

So I am having some issues with my spriteKit game since upgrading to iOS 9 and even after upgrading to Swift 2. I mentioned 1 here Atlas images wrong size on iPad iOS 9
However I am having 2 more issues I cannot fix.
1)
All my particle effects dont work anymore. This is the code I use and they are just not showing up anymore. If I just use SKEmitterNode than it works, but I prefer to add the SKEmitterNode to a SKEffectNode as it blends much better with backgrounds etc.
This is the code.
let particlesPath = NSBundle.mainBundle().pathForResource("Thrusters", ofType: "sks")!
let particles = NSKeyedUnarchiver.unarchiveObjectWithFile(particlesPath) as! SKEmitterNode
let particleEffects = SKEffectNode() //blends better with background when moving
particleEffects.zPosition = 20
particleEffects.position = CGPointMake(0, -50)
particleEffects.addChild(particles)
addChild(particleEffects)
I read this
http://forum.iphonedev.tv/t/10-8-skeffectnode-or-xcode-7-or-my-issue/669
and it claims it was fixed, but it wasn't.
2)
My Game Center banners when I log in or when an achievement pops are now using the portrait banner, even though my game is in landscape. Therefore banners only cover half the top screen. It looks so bad and since there is no actually code for banners I dont even know where to start.
Anyone else facing these issues, its frustrating.
Thanks for any help or support.
Some updates to this old question. Believe it or not in regards to the particles, apple recently replied to my 1 year old BugReport to see if it is fixed in iOS 10. LOL
I heard rendering particles via a SKEffectNode way is not necessarily ideal in regards to performance and I am not using it anymore. Therefore I am not sure if the bug is still occurring with the later Xcode and iOS 9 updates or in iOS 10 beta.
In regards to the adMob banner, I simply had to change
let adMobBannerAdView = GADBannerView()
to
var adMobBannerAdView: GADBannerView?
and delay initialisation until ViewDidLoad/DidMoveToView.

corona sdk button's images not visible/misplaced

I just installed the sdk and run in creating sample app project.
I ended up with a folder full of icons and 3 classes that were to show me how things work.
The problem I noticed is that the code creates buttons that should have a background image but only the text is visible. Images are in the same folder and spelling is correct.
The auto-generated code looks like this:
playBtn = widget.newButton{
label="Play Now",
labelColor = { default={255}, over={128} },
default="button.png",
over="button-over.png",
width=154, height=40,
onRelease = onPlayBtnRelease -- event listener function
}
playBtn.x = display.contentWidth*0.5
playBtn.y = display.contentHeight - 125
Also the text doesn't change color. When I added another button below with my image below the auto created one I was able to see my tiny part of my image in the top left corner. The button was also visible when moving to net scene. How come?
To help solve your color issue you need to change the values. Corona recently changed to decimal colors, the range is from 0 to 1 versus 0 to 255. Anything over 1 will result in a 1 being used for the color.
So basically your colors need to be divided by 255 to get the proper value. You can either have the code divide it or you can divide the value yourself. You can read a post about it here.

Xcode 4 - Dynamic Interface Tutorial needed

I'm trying to create a news viewer with Xcode 4. This should look like the following:
===============================
Title comes here ------- Date
Image
News Body
================================
As you can see, the news body must be pushed downward depending on the size of the image. The image must be pushed downward as the height of the title varies. I know I have to do some programming to position them dynamically. The only problem is I'm not familiar with CGRect and Frame things...
Where can I find a tutorial or sample code I can take a look and get some ideas? Practical codes or tutorials would be appreciated as just reading documentation doesn't really give me a clear idea how to approach this.
UILabel provides -sizeWithFont:constrainedToSize:lineBreakMode: which will allow you to determine the size needed to fit the text you wish to display. I put together an example of resizing UILabels when I first ran into a similar problem and posted it here: http://blog.carbonfive.com/2009/07/10/resizing-uilabel-to-fit-text/
I'm afraid that's rather old now but I think should still be of some use.

TTTableViewController is a bit jumpy?

I'm using the TTTableViewController and datasource and I notice every time a new cell is being loaded it is a little bit sticky. My source code is too long to post so I was wondering if there were any tips or things to look out for to optimize the three20 table view?
This is very interesting. I have a tableView that creates many UIImageViews in lazy loaded cells and replacing imageWithContentsOfFile virtually removed a slight pause when the cells were being recreated. Each cell has 1 changing image, and 2-3 images that never change.
According to this thread, imageNamed should not be used: img_data_lock iphone - imageNamed vs imageWithContentsofFile, I have not noticed any crashes with imageNamed, can you explain why this is so?

Resources