Beginning Mac OS X Snow Leopard Programming by Michael Trent & Drew McCormack
Author:Michael Trent & Drew McCormack
Language: eng
Format: epub
ISBN: 9780470577523
Publisher: Wiley
* * *
SUBCLASSING CONTROLS IN INTERFACE BUILDER
Occasionally you need to create your own custom controls to provide the right user experience within your application. Although you can create new controls from scratch by creating a custom NSControl subclass, you can often start from an existing control and just add your custom behavior. After all, if you need a special control that acts like a slider, you could save a lot of time and trouble by re-using the implementation in the NSSlider class.
This practice of starting from an existing control applies to Interface Builder as well. After you have decided to subclass a control from an existing class, drag the existing class into your interface from the Library and then change its Class in the Identity Inspector. You have already seen examples of both these techniques: you have dragged many controls out of the Library, and you have changed the class of a nibâs Fileâs Owner instance. You simply need to apply these techniques to other controls to modify their behavior through subclassing.
In the following Try It Out, you create a custom image view class that provides some custom resize logic for that view. This image view is meant to resize itself freely when its window changes size, as long as the image view is never smaller than its contents. This custom class simply inherits the rest of its behavior from the existing NSImageView class.
TRY IT OUT Creating a Custom NSImageView Subclass
1. In Xcode, create a new Objective-C object subclassed from NSObject named SlideImageView.m. Remember to create the corresponding header file.
2. In SlideImageView.h, change the superclass for SlideImageView from NSObject to NSImageView:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4127)
Ego Is the Enemy by Ryan Holiday(3982)
Offensive Shellcode from Scratch by Rishalin Pillay(3621)
Exploring Deepfakes by Bryan Lyon and Matt Tora(3183)
Robo-Advisor with Python by Aki Ranin(2958)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(2839)
Speed Up Your Python with Rust by Maxwell Flitton(2832)
Liar's Poker by Michael Lewis(2806)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(2785)
Agile Security Operations by Hinne Hettema(2782)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(2780)
Extreme DAX by Michiel Rozema & Henk Vlootman(2777)
Essential Cryptography for JavaScript Developers by Alessandro Segala(2721)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(2710)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2628)
Python for ArcGIS Pro by Silas Toms Bill Parker(2623)
Cryptography Algorithms by Massimo Bertaccini(2615)
Incident Response Techniques for Ransomware Attacks by Oleg Skulkin(2609)
Distributed .NET with Microsoft Orleans by Bhupesh Guptha Muthiyalu Suneel Kumar Kunani(2609)