Youtube Fails on device, works on Simulator
I'll have to answer my own question. The problem was that I used to show the video inside UITableViewHeader
by implementing the needed delegates:
viewForHeaderInSection
heightForHeaderInSection
I have only one section so I returned value there only if section == 0
I do not know what exactly causes this issue, but probably multiple calling of the method leads to this. What I did was to simply move the initialisation of UIWebView
inside viewWillAppear
and set it as tableViewHeaderView
. So I'm now setting it only once and the problem is gone:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
dispatch_once(&token) {
self.initHeader()
}
}
How to add video to iphone simulator
okey, try this:
- (void) downloadVideo {
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sepwww.stanford.edu/sep/jon/trash/poolwaves.mov"]];
You can change the temp.mov to temp.m4v to save the vid in m4v.
NSString *tempPath = [NSString stringWithFormat:@"%@/temp.mov", NSTemporaryDirectory()];
[imageData writeToFile:tempPath atomically:NO];
UISaveVideoAtPathToSavedPhotosAlbum (tempPath, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}
- (void) video: (NSString *) videoPath
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo {
NSLog(@"Finished saving video with error: %@", error);
}
if you change the url to your moviefile, this should work really well...
the movies are saved in this directory: /Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM
but you are right, if i copy a file to it, it won't show up in the simulator
greets
Related Topics
I Cannot Access My Array Objects Anywhere, How to Access Them in Swift
How to Fix Uilabel Text Spacing
Schedule Local Notification Every N Days (Timezone Safe)
Nsclassfromstring Returning Nil for Nested Class
Reversing a Range Results in Mismatching Types
Load Offline Cached JSON Using Afnetworking
Format String with Variadic Arguments
Uitabbar Transition Issue Below iOS 11 Swift
Swift:'(Nsobject, Anyobject)' Does Not Have a Member Named 'Subscript'
Can't Dismiss Navigation Controller in Swift
Swift - Uitableview Didselectrowatindexpath & Diddeselectrowatindexpath Add & Remove Indexpath Ids
How to Set Response Data into Todayextenstion Widget
Checkbox Uitableview with Different Sections