iboutlet

When does an IBOutlet initialize?

我与影子孤独终老i 提交于 2019-12-06 03:30:03
问题 I set up an outlet for a text view via Interface Builder. The text view loads fine, however I can't access any of the properties of it programmatically because the outlet is always nil . When does it instantiate? Even after my applicationDidFinishLoading gets called, it's still not "alive" or unarchived. 回答1: An outlet doesn't instantiate because an outlet is a variable (or property). The objects in a nib are instantiated when that nib is loaded, and they are assigned to each outlet as

Xcode 4.3: duplicated connections of an IBOutlet

一笑奈何 提交于 2019-12-05 20:27:39
I am learning Stanford CS193p course with Xcode 4.3.3. I think the screenshot below is pretty much self-explaining. But i will describe the problem with words anyway. I control-drag a UILabel from storyboard to corresponding implementation file to make the IBOutlet @property. Then I see two connections displayed when clicking the filled circle in the left side of the editor where shows line numbers. I don't know how to delete it. Moreover, I see only ONE connection in storyboard's connections inspector of the UIlabel. More weird, when I try to set the UILabel's text inside the setter of a

Launch screen is black when set to a storyboard file

耗尽温柔 提交于 2019-12-05 16:59:16
I am using a storyboard to get the correct height of a navigation bar in my launch image . However, after customizing the view controller a bit, it now displays a black screen instead of a launch image. When I set it to a brand new view controller, everything is fine. It seems like the original view controller is now in a bad state. How can I fix this? (I'm running iOS 8.2 simulator on Xcode 6.2.) The problem in this case was that there was an outlet set on the view controller . If there are any outlets on the initial view controller (or, if the initial view controller is a navigation

IBOutlet instances are (null) after loading from NIB

蓝咒 提交于 2019-12-05 12:51:56
问题 I am working on an iPhone app and am getting (null) references to IBOutlet fields in my controller. I have a UIViewController subclass that is set as the File's Owner in my XIB. I have a set of UI elements that are wired into the controller. After loading from NIB and attempting to set properties on those UI elements, I find that they are (null). To clarify, some code: ExpandSearchPageController.h: @interface ExpandSearchPageController : UIViewController { IBOutlet UITextView *

Accessing IBOutlet from another class

空扰寡人 提交于 2019-12-05 10:44:40
I am calling a class function from my ViewController class like this: Buttons.set_cornerRadius(10) I have another .swift file where I have the function declared: class Buttons { class func set_cornerRadius(radius: CGFloat) { ViewController().someButton.layer.cornerRadius = radius } } When I'm trying to run this it throws the error: "Unexpectedly found nil while unwrapping an optional Value" . I checked the Storyboard-IBOutlet connections already. Everything is connected right. If I call the method in the same class like this, everything works: class ViewController: UIViewController { @IBOutlet

Objective-C Custom Class Actions and Outlets

一笑奈何 提交于 2019-12-05 07:35:07
问题 I am attempting to create a custom subclass of a UIView as follows: I created a .xib with a UIView that contains a Picker object and Toolbar object, hooked up the Outlets and actions. CustomPickerView.h #import <UIKit/UIKit.h> @interface CustomPickerView : UIView @property (strong, nonatomic) IBOutlet UIDatePicker* datePicker; @property (strong, nonatomic) IBOutlet UIBarButtonItem* doneButton; -(IBAction) buttonDonePush:(id)sender; @end CustomPickerView.m #import "CustomPickerView.h"

Reasons for an IBOutlet to be nil

流过昼夜 提交于 2019-12-05 05:40:46
What are the reasons why an IBOutlet (connected) could be nil ? I have one in may application which is always nil , even if I recreate everything from scratch (declaration and control). It could be that your nib is messed up, but I find a common reason is having two instances where you think you only have one, and the one you're using in your code is not the one you connected. If you've also defined a loadView method that creates the view, it is possible based on how you initialize it. If you initialize it using alloc-init and the nib name is not the same as class name, then you can have a

iOS - What is best way to manage memory for IBOutlets?

为君一笑 提交于 2019-12-05 01:28:04
I've been reviewing the Apple docs and sample code to try to determine the best way to manage memory for IBOutlets. I'm a little confused, to say the least. The CurrentAddress sample code declares IBOutlets as properties: @interface MapViewController : UIViewController <MKMapViewDelegate, MKReverseGeocoderDelegate> { MKMapView *mapView; UIBarButtonItem *getAddressButton; } @property (nonatomic, retain) IBOutlet MKMapView *mapView; @property (nonatomic, retain) IBOutlet UIBarButtonItem *getAddressButton; Great. And these are released in dealloc: - (void)dealloc { [mapView release];

IBOutlet isn't connected in awakeFromNib

*爱你&永不变心* 提交于 2019-12-04 22:18:07
The sample code linked here works great and allows a UIScrollView to display images with paging and preview of the images before and after the current image: http://blog.proculo.de/archives/180-Paging-enabled-UIScrollView-With-Previews.html https://github.com/alexrepty/Paging-Enabled-UIScrollView-With-Previews I'm trying to encapsulate the example in a single control that can be reused. So I created a PagingScrollView: @interface PagingScrollView : UIView { IBOutlet UIScrollView * scrollView; } @property (nonatomic,retain) IBOutlet UIScrollView * scrollView; @end with dirt simple

How would I use polymorphism to allow a method to accept multiple classes, but with IBOutlets?

前提是你 提交于 2019-12-04 21:50:42
I have a specific method that accepts a UIView object, and I want to pass objects to it that can be of one of two classes. So say it accepts a UIView that represents an animal, I want to be able to pass a DogView and a CatView or other animal-type classes potentially. Within that method I want to set the nameLabel view, which all animals have. How do I set it up so I'd be able to do this? My first reaction was to have a super class (such as AnimalView ) that has the nameLabel variable on it, and then subclass it for each new animal. However, if I want the nameLabel to be an outlet, it doesn't