iboutlet

How do I connect a IBOutlet to a UIView?

99封情书 提交于 2019-11-29 05:07:33
I'm trying to switch views after an animation as seen: [UIView beginAnimations: @"Fade Out" context:nil]; [UIView setAnimationDelay:1.0]; [UIView setAnimationDuration:0.25]; splash.alpha = 0.0; [UIView commitAnimations]; [self.view addSubview : view]; At the [self.view addSubview : view]; I have to add a name for the view for it to add, so I made an IBOutlet like so: (on the first view controller's .h file) IBOutlet UIView *main; But when I try to connect the *main UIView to the view on the storyboard, it wont let me... Thanks so much guys. Your point of confusion is between creating UI

(Swift) PrepareForSegue: fatal error: unexpectedly found nil while unwrapping an Optional value

家住魔仙堡 提交于 2019-11-29 04:21:11
DetailViewController: @IBOutlet var selectedBundesland: UILabel! TableViewController: override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "BackToCalculator") { var vc:FirstViewController = segue.destinationViewController as FirstViewController vc.selectedBundesland.text = "Test" } IBOutlet is connected! Error: fatal error: unexpectedly found nil while unwrapping an Optional value I read multiple pages about Optionals but i didn't know the answer to my problem. Do you need more information about my project? You cannot write directly to the

When should I use Strong vs Weak for IBOutlets (further clarification)

半腔热情 提交于 2019-11-29 03:35:22
I thought I understood it clearly from this question --> Should IBOutlets be strong or weak under ARC? but I recently had a discussion which left me totally confused. Can someone just confirm if the following is correct? (if this is a duplicate I didn't mean to break any rules.. just need clarification as I can understand diagrams better than words..) Under ARC (MacOSx) view1 = strong MainView = weak (In WindowControllerA) MainView = strong (In ViewControllerB) view2 = strong view3 = weak (In ViewcontrollerB) view3 = strong (In ViewControllerC) If this is correct then can someone confirm

awakeFromNib, outlets and storyboards: is the documentation wrong?

风格不统一 提交于 2019-11-29 02:58:58
According to the NSObject UIKit Additions Reference , outlet variables should be set by the time awakeFromNib is called (emphasis all mine): The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established. ... Important: Because the order in which objects are instantiated from an archive is not guaranteed, your initialization methods should not

Detect which button is pressed with an UIButton Array

淺唱寂寞╮ 提交于 2019-11-29 01:11:18
问题 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

iOS loadNibNamed confusion, what is best practice?

六月ゝ 毕业季﹏ 提交于 2019-11-28 20:27:14
I'm familiar with most of the process of creating an XIB for my own UIView subclass, but not everything is working properly for me - it's mostly to do with the IBOutlets linking up. I can get them to work in what seems like a roundabout way. My setup is this: I have MyClass.h and MyClass.m. They have IBOutlets for a UIView (called view) and a UILabel (called myLabel). I added the 'view' property because some examples online seemed to suggest that you need this, and it actually solved an issue where I was getting a crash because it couldn't find the view property, I guess not even in the UIView

Strange error when adding items to prototype cells in storyboard-IB

核能气质少年 提交于 2019-11-28 18:09:37
I have quite a large project (~20 scenes). One of which is a TableViewController with a custom UITableViewController class. I have given the cell a reuse identifier, and added a label to it. When I try and Ctrl+Drag the label to the UITableViewController header file to create an outlet, I get the following error: error: Illegal Configuration: Connection "tableInfoView" cannot have a prototype object as its destination. What is this? Am I overlooking something obvious? Or do I need to create a custom cell class and drag the outlet to that? If so, how do I then specify the data which is

UIAlertView crashes when added to app

 ̄綄美尐妖づ 提交于 2019-11-28 14:32:39
I am trying to impliment a basic UIAlertView into my app (I am using storyboard). But when I run my app, it goes to the debugger screen after stalling at the app's loading screen. my .h: #import <UIKit/UIKit.h> @interface MindTripAnim :UIViewController { IBOutlet UIImageView *animation; } - (IBAction)showMessage:(id)sender; @end and my .m: #import "MindTripAnim.h" @interface MindTripAnim () @end @implementation MindTripAnim - (void)viewDidLoad { animation.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"trips1.png"], [UIImage imageNamed:@"trips2.png"], [UIImage imageNamed:@

Make a UIBarButtonItem disappear using swift IOS

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 11:52:38
I have an IBOutlet that I have linked to from the storyboard @IBOutlet var creeLigueBouton: UIBarButtonItem! and I want to make it disappear if a condition is true if(condition == true) { // Make it disappear } Do you really want to hide/show creeLigueBouton ? It is instead much easier to enable/disable your UIBarButtonItems. You would do this with a few lines: if(condition == true) { creeLigueBouton.enabled = false } else { creeLigueBouton.enabled = true } This code can even be rewritten in a shorter way: creeLigueBouton.enabled = !creeLigueBouton.enabled Let's see it in a UIViewController

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

柔情痞子 提交于 2019-11-28 08:49:44
问题 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? 回答1: Either one works fine in my experience. What doesn't work is declaring both the instance variable and the property