You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to determine if the phone being used is an iPhone x within a collectionview & when i run the iPhone X in the simulator, it running the default code rather than the iPhoneX code, any idea as to why this is happening? Here is the code.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let deviceType = UIDevice.current.deviceType
switch deviceType {
case .iPhoneX:
print("is this the iPhone x?")
if index == 1 || index == 3 {
width = (collectionView.bounds.width)
} else {
width = (collectionView.bounds.width) / 5
}
default:
if index == 1 || index == 3 {
print("this is not the iphone x")
width = (collectionView.bounds.height)
} else {
width = (collectionView.bounds.height) / 3
}
}
return CGSize(width:width, height:width)
}
So it appears that there is a separate device for the simulator, how exactly am I supposed to test code on an iPhone X if this is unable to detect the simulator type?
The text was updated successfully, but these errors were encountered:
Hi. You are really cannot detect simulator type, but you can adjust collection size according to display screen size. There is no really need to know if this is X or SE, for example.
I am currently trying to determine if the phone being used is an iPhone x within a collectionview & when i run the iPhone X in the simulator, it running the default code rather than the iPhoneX code, any idea as to why this is happening? Here is the code.
So it appears that there is a separate device for the simulator, how exactly am I supposed to test code on an iPhone X if this is unable to detect the simulator type?
The text was updated successfully, but these errors were encountered: