Reputation: 7549
I created inside of viewDidLoad
the next view:
var myView = UIView(frame: CGRectMake((width-50)/2, (height-50)/2, 50, 50))
and set to it:
myView.alpha = 0
But I want to make it myView.alpha = 1
when user tapped on tableView cell
. But it does not visible from
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { ... }
How can I do it visible from there? Do not offer to create it, view, in XCode visually.
It prints the next error:
'ViewController' does not have a member named 'myView'
Upvotes: 1
Views: 77
Reputation: 23882
Define the variable under your @IBOutlet
s
var myView:UIView!
var width:CGFloat!
var height:CGFloat!
And in your viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
width = mytableview.frame.size.width
height = mytableview.frame.size.height
myView = UIView(frame: CGRectMake((width-50)/2, (height-50)/2, 50, 50))
self.view.addSubview(myView)
}
Upvotes: 2
Reputation: 2471
you need to add the created view into the main View
var myView = UIView(frame: CGRectMake((width-50)/2, (height-50)/2, 50, 50))
self.view.addSubview(myView)
Upvotes: 0