Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:20:01+00:00 2026-06-14T05:20:01+00:00

I’m fairly new to coding for the iOS platform and objective C in general.

  • 0

I’m fairly new to coding for the iOS platform and objective C in general. I’m writing a simple iPhone app utilizing storyboard that has a tall png file displayed via UIImageView embedded within a UIScrollView and a button next to it that will play a movie.

My issue is that when the movie finishes/exits and comes back to the original screen, the scrolling within the UIScrollView does not work. I have nailed down the “cause”. It occurs when I add the MPMoviePlayerViewController object.view to the self.view subview. But I’m not sure how to rectify this issue. Here is my distilled code:

.h file

@interface StuffViewController : UIViewController 

@property (strong,nonatomic) IBOutlet UIImageView *imageView;
@property (strong,nonatomic) IBOutlet UIScrollView *scrollView;

-(IBAction) playMovie;
-(void) moviePlayBackDidFinish:(NSNotification*)notification;

@end

.m file

-(void) viewDidLoad {
    self.imageView.image = [UIImage imageNamed:@"image.png"];
}

-(void) viewDidAppear:(BOOL)animated {
    self.scrollView.contentSize = self.imageView.image.size;
}

-(void) playMovie {
    NSURL *movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"movieTitle" ofType:@"mp4"]];
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] 
                                                initWithContentURL:movieURL];
       [[NSNotificationCenter defaultCenter] addObserver:self
                                        selector:@selector(moviePlayBackDidFinish:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:moviePlayer];
    [moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
    [[self view] addSubview:moviePlayer.view];   //SCROLLING BREAKS HERE
    [moviePlayer setFullscreen:YES];
    [moviePlayer play];
}

-(void)moviePlayBackDidFinish: (NSNotification*)notification {
    MPMoviePlayerController *movieDone = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [movieDone.view removeFromSuperview];
    [movieDone setFullscreen:NO];
}

I have determined the culprit by commenting out sections, and like I said, the scrolling “locks” at the “[[self view] addSubview:moviePlayer.view];” line and doesn’t recover until I navigate to a different view and then come back.

Any and all help on this would be greatly appreciated.

EDIT: I have discovered an interesting wrinkle that might help discover the underlying issue.

I have been using MPMoviePlayerController this whole time. However upon switching to MPMoviePlayerViewController some interesting things have been happening.

Here is the changed -(void)playMovie

-(void) playMovie {
   self.scrollView.contentOffset = CGPointZero;
   NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                    pathForResource:totalTitle ofType:@"mp4"]];
   MPMoviePlayerViewController *playerController =  [[MPMoviePlayerViewController alloc] initWithContentURL:url];
   [self presentMoviePlayerViewControllerAnimated:playerController];
   playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
   [playerController.moviePlayer play];
   playerController = nil;
}

What is interesting is that the UIScrollView will still work, HOWEVER, if it has been scrolled down at all it will no longer be able to scroll up from where it was when the movie started. I fixed this by adding self.scrollView.contentOffset = CGPointZero at the beginning of the playMovie to tell the scrollView to move to the top (so there would be nothing above it to have to scroll back to). I assume that adding some sort of if-statement to the code in viewDidAppear that would keep scrollView.contentSize from re-executing might fix the problem of not being able to scroll back up, however I like the ‘cleanness’ of it starting back at the top.

One last issue though. Using MPMoviePlayerViewController like this has caused a number of interesting errors to pop up in my debugger right when MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; line is executed. They are as follows:

Oct 25 10:25:51 Compy.local AppName[14590] <Error>: CGContextSaveGState: invalid context 0x0 
Oct 25 10:25:51 Compy.local AppName[14590] <Error>: CGContextClipToRect: invalid context 0x0
Oct 25 10:25:51 Compy.local AppName[14590] <Error>: CGContextTranslateCTM: invalid context 0x0
Oct 25 10:25:51 Compy.local AppName[14590] <Error>: CGContextDrawShading: invalid context 0x0
Oct 25 10:25:51 Compy.local AppName[14590] <Error>: CGContextRestoreGState: invalid context 0x0

It doesn’t seem to break anything. I tend to be a perfectionist when it comes to errant error statements however. I’ve done some research on these errors, however I haven’t found anything suitable that would lend a strong hand in this situation.

Thanks for all the help so far! Once again, I would appreciate any and all help on this as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:20:05+00:00Added an answer on June 14, 2026 at 5:20 am

    The cause of the problem was the use of ‘Autolayout’ in Storyboard. I’m not 100% sure why it would cause it problem after playing a movie and not before. However I fixed it by either:

    A: removing Autolayout

    or

    B: playing with the constraint functions until it ended up working. (Changing the height of the UIImageView to 0 and changing the Equals: Default to have the lowest priority possible.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.