Swift 4 Expression type’@value CGRect’ is ambiguous without more context
For example, there is now a class:
class ImageListView: UIView {
var moment: Moment!
var tapSmallView: ((_ iamgeView: UIImageView) -> Void)?
var imagesArray: [UIImageView]!
//ImagePreviewView is another custom class, which has a scrollView
var imagesPreview: ImagePreviwView!
func setMoment(_ moment: Moment) {
self.moment = moment
let count = moment.ImageCount
imagesPreview.scrollView.contentSize = CGSize(width: imagesPreview.frame.width*count, height: imagesPreview.frame.height)
}
}
In this case, setting the contentSize of the scrollView will report an error, because count is of type Int. If we do any mathematical operations on screenBounds, please make sure to check the type matches.
You must change the type:
imagesPreview.scrollView.contentSize = CGSize(width: imagesPreview.frame.width*CGFloat(count), height: imagesPreview.frame.height)
Read More:
- How to Solve BANKEX/web3swift Error
- How to Solve Spring Cloud Error context has been closed already
- How to Solve Error: Element ‘dependency’ cannot have character [children], because the type’s content type is element-
- How to Solve Keil Error: error: #29: expected an expression
- SQL Server Error: Arithmetic overflow error converting expression to data type int.
- How to Solve Uncaught Error: Syntax error, unrecognized expression:#
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- How to Solve Error: Missing type map configuration or unsupported mapping
- How to Solve TypeError: type numpy.ndarray doesn’t define __round__ method
- How to Solve TypeError: type numpy.ndarray doesn‘t define __round__ method
- How to Solve Springboot Error: Failed to convert value of type
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- How to Solve ERROR – unregister mbean error javax.management.InstanceNotFoundException: com.alibaba.druid:type=
- How to Solve Docker Error: elasticsearch exception: type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
- How to Solve Error: “initializer element is not constant”
- The problem of error reporting caused by fluent swift
- [Solved] swagger3 Error: org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- Error: env [NODE_ENV] is not set (How to Solve)
- How to Solve Cocos creator label text is too many error