iboutlet

Reasons for an IBOutlet to be nil

夙愿已清 提交于 2019-12-01 02:05:00
问题 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). 回答1: 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. 回答2: If you've also defined a loadView method that creates the view, it is possible based on how you initialize

Interface Builder won't allow connections to custom UIView class?

情到浓时终转凉″ 提交于 2019-11-30 13:09:41
Using Xcode 4.3.3, I can't figure out how to connect outlets in a custom UIView class with objects created in Interface Builder. In one ViewController, I have a variety of buttons, sliders, etc that I'm trying to group into Views. So, within that ViewController in IB, I added 3 views. Only 1 view will be visible at any given time. I derived custom UIView classes to handle each of these 3 views. My view controller instantiates each of the classes. I selected the view(s) in IB, opened the Identity Inspector and set the Class(es) to my custom class(es). But when I tried dragging connections from

Create an outlet in storyboard to an inherited property

↘锁芯ラ 提交于 2019-11-30 09:27:49
问题 I'd like to create a basic view controller class BasicController with two subclasses SubclassController and AnotherSUbClassController. BasicController controls view that have a button inside them, so there should be a weak var buttonThing: UIButton? property in it. In the actual implementation I want to use the subclasses in various parts of the interface: I want to draw them in storyboard, put buttons in that drawings, and connect the buttons to the inherited buttonThing property via an

Declaring IBOutlet inside or outside @interface?

别等时光非礼了梦想. 提交于 2019-11-30 08:43:39
sorry If am I being too picky on this one but I am learning iOS programming now and I've seem some people who declare the IBOutlet like this: IBOutlet attached to property #import <UIKit/UIKit.h> #import "CustomCell.h" @interface CustomTableViewController : UITableViewController { CustomCell *customCell; } @property (nonatomic, retain) IBOutlet CustomCell *customCell; @end And some declaring like this: IBOutlet attached to the declaration inside the interface #import <UIKit/UIKit.h> #import "CustomCell.h" @interface CustomTableViewController : UITableViewController { IBOutlet CustomCell

How to make IBOutlets out of an array of objects?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:07:54
I want to make an array with a bunch of UIImageViews I have in Interface Builder. Instead of having 20 or 30 IBOutlet UIImageView *img1; and linking them all that way, and then putting them into an array, is there a way to declare an array of IBOutlet UIImageViews? Just so I don't have so many declarations in my header file. It is possible, it’s called outlet collection . This is the way to define an outlet collection: @property(retain) IBOutletCollection(UIImageView) NSArray *images; Now you can stick more than one object into the outlet in the Interface Builder, the array will be created for

Detect which button is pressed with an UIButton Array

时光怂恿深爱的人放手 提交于 2019-11-30 04:04:25
I have an UIButton array like this: @property (nonatomic, retain) IBOutletCollection(UIButton) NSArray *btn_Impact_Collection; and I have this function: - (IBAction)impactAction:(id)sender; In the XIB file I have nine button, each button is connected to btn_Impact_Collection Array with the Referencing Outlet Collection. Moreover the Touch_inside property of each button is connected to the function ImpactAction. Now, when a button is clicked the ImpactAction function is called, but inside this function, how can i know which button is pressed? Thanks in advance for the answer! Cast sender to

IBOutlet is nil inside custom UIView (Using STORYBOARD)

倖福魔咒の 提交于 2019-11-30 01:49:30
I have a custom UIView class. Inside it I have declared an IBOutlet property for UIImageView . #import <UIKit/UIKit.h> @interface SettingItem : UIView{ } @property (strong, nonatomic) IBOutlet UIImageView *myImage; @end Now i am using storyboard. There is a viewcontroller. I dragged UIView to viewcontroller. I dragged one UIImageView as a subview of above UIView . I set the "SettingItem" class to UIView from storyboard. I connected the outlet to myImage by normal dragging from outlets of SettingItem from utilities window. SettingItem implementation #import "SettingItem.h" @implementation

What is the difference between IBOutlet as a property or as a variable?

谁说我不能喝 提交于 2019-11-29 15:28:09
There are two different methods to declare IBOutlet. In @interface section as variable: IBOutlet UIButton *exampleButton; Below the curve bracket but before @end of .h file as property: @property (nonatomic, retain) IBOutlet UIButton *exampleButton; What is the difference between these two methods and where should I use each one? Which method is better and in what cases? Either one works fine in my experience. What doesn't work is declaring both the instance variable and the property "IBOutlet" -- that seems to really confuse things. If for some reason you want to avoid providing public access

Declaring IBOutlet inside or outside @interface?

邮差的信 提交于 2019-11-29 12:19:23
问题 sorry If am I being too picky on this one but I am learning iOS programming now and I've seem some people who declare the IBOutlet like this: IBOutlet attached to property #import <UIKit/UIKit.h> #import "CustomCell.h" @interface CustomTableViewController : UITableViewController { CustomCell *customCell; } @property (nonatomic, retain) IBOutlet CustomCell *customCell; @end And some declaring like this: IBOutlet attached to the declaration inside the interface #import <UIKit/UIKit.h> #import

All IBOutlets are nil

99封情书 提交于 2019-11-29 12:02:10
Hello I am initializing viewController using this code: var aboutUsViewController = self.storyboard?.instantiateViewControllerWithIdentifier("AboutUsViewController") as AboutUsViewController After this I move to aboutViewController . However all my IBOutlets on aboutViewController are nil ! Why is that so? I am using MMDrawer library in order to have side bar menu. var aboutUsViewController = self.storyboard?.instantiateViewControllerWithIdentifier("AboutUsViewController") as AboutUsViewController var aboutUsNavController = UINavigationController(rootViewController: aboutUsViewController) var