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 8070723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:29:39+00:00 2026-06-05T13:29:39+00:00

Im trying to save a screen from my app with th use of a

  • 0

Im trying to save a screen from my app with th use of a button rather than the home button/on off affair. Im getting an error with code using self.

“Property Window not found on object of type “…my view controller”

- (IBAction)saveto:(id)sender {
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
    UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
else
    UIGraphicsBeginImageContext(self.window.bounds.size);
[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * data = UIImagePNGRepresentation(image);
[data writeToFile:@"my.png" atomically:YES];

(Image view is declared as outlet in .h)

I know im missing something basic here but cant figure it out, any help greatfully received

  • 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-05T13:29:41+00:00Added an answer on June 5, 2026 at 1:29 pm

    Its self.view.window I’m pretty sure. 🙂

    - (IBAction)saveto:(id)sender {
        if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
            UIGraphicsBeginImageContextWithOptions(self.view.window.bounds.size, NO, [UIScreen mainScreen].scale);
        else
            UIGraphicsBeginImageContext(self.window.bounds.size);
        [self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        NSData * data = UIImagePNGRepresentation(image);
        [data writeToFile:@"my.png" atomically:YES];
    }
    

    Window is a property on UIView.

    http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

    window The receiver’s window object, or nil if it has none.
    (read-only)

    @property(nonatomic, readonly) UIWindow *window Discussion This
    property is nil if the view has not yet been added to a window.

    Availability Available in iOS 2.0 and later. Declared In UIView.h

    UIViewController doesn’t have a window property. However it has a view property which does have a window property 🙂

    http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

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

Sidebar

Related Questions

I am trying to identify a screen in a multi-monitor setup to save some
I am trying to use xlwt to create MS-Excel files from the contents of
I'm trying to save a file (pdf or image) uploaded from a form into
I'm trying to download a mp4 file from a server, then save it in
I am trying to save the data from a loop of logical tests. So
I'm trying to use OO to convert RTF input (from MS Word 2000) to
I'm trying to show all images from a selected category on screen. Which is
I'm trying to write some code that deletes an image off the hard-disk once
I am trying to use charts from the WPF Toolkit (with LineSeries) and I
Simple question from an absolute n00b. I'm trying to create an edit content screen

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.