I want to display captured video using MPMoviePlayer
for that purpose I designed one customcell and number of sections is one and I am loading ten by ten records in tableView
so number of rows depends on array count so every time ten by ten records displaying from getService
and my problem is frame is not setting properly in cell for that purpose I wrote entire code in one method and called that method in viewDidAppear()
and when getting cell reference in viewDidAppear()
getting fatal error in NSIndexPath
I am thinking that viewDidAppear()
is calling before I am getting cell reference so how to solve this problem please tell me any solution?
Asked
Active
Viewed 180 times
-2

Unome
- 6,750
- 7
- 45
- 87

Mahesh Kolagatla
- 91
- 1
- 4
-
3Please edit your post to not be **one GIANT run on sentence**. This makes it very difficult to read. Also code examples really help. "Please tell me a solution" without a solid grasp of what you are already doing is not a realistic request. – Unome Aug 14 '15 at 19:55
1 Answers
1
You are not supposed to manipulate with frames of cells from viewDidAppear
of your view controller.
A frame consists of: left, top, width, and height.
- left is always 0;
- top is specified by a table and is based on the index path and heights of previous cells, section headers, and a table's header;
- width is always equal to a width of the table;
- height you can specify by yourself by overriding
UITableViewDelegate
's methodoptional func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
But most likely you are interested in a different thing. And you want to layout UI elements within you cells. If yes, you have a few ways to do this:
- Override
func layoutSubviews()
method in the cell and set all frames you want. This method is called every time when frame is changed. So it's exactly what you need. - Also you can specify the desired layout using auto layouts. This may be done in a storyboard/xib file or in code (in a designated constructor of the cell).

Artem Stepanenko
- 3,423
- 6
- 29
- 51