iboutlet

Should IBOutlet be weak or strong var? [duplicate]

不想你离开。 提交于 2019-12-03 10:46:00
问题 This question already has answers here : Should IBOutlets be strong or weak under ARC? (11 answers) Closed 3 years ago . I'm using Xcode 6.2 for iOS projects. In older versions of Xcode, when a connection was create for an IBOutlet, it was always weak storage. Now when I create connections, they are defaulted to strong. I leave it that way and don't notice any difference. Which version of Xcode did the default change to strong and why? 回答1: Yes, previously outlets should generally be weak but

IBOutlets and IBactions require ! in the end

大兔子大兔子 提交于 2019-12-03 08:15:06
I tried to start and go from Obj-C to Swift today and I was reading the documentation. I tried to create an easy IBOutlet in Swift and it constantly gave me those errors. View Controller has no initialiser required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } IBOutletproperty has non-optional type 'UILabel' and that constantly pops up with this code: @IBOutlet var outputLabel : UILabel but when I add an ! mark, it's running without errors like so @IBOutlet var outputLabel : UILabel! Same thing happens for IBActions... virus First of all get to know,

Should IBOutlets be ivars or properties?

余生颓废 提交于 2019-12-03 07:50:48
Though I'm sure they exists, I'm having difficulties finding or pinning down an official best practice for declaring outlets in a ViewController. There are 3 options so far as I can see: ivar only property only property backed with an ivar Xcode currently crashes when I try and auto-generate a property by dragging into my ViewController from IB, but from what I remember, doing so creates a property without an ivar. It is also possible to drag into the ivar section and this will create an ivar without a property. This suggests that property-only and ivar only outlets are both OK with apple. So

UISegmentedControl deselect (make none of the segments selected)

為{幸葍}努か 提交于 2019-12-03 05:30:42
问题 in fact the title contains my question. I have a UISegmentedControl, and need to deselect currently selected tab. I tried: [menu setSelectedSegmentIndex:-1]; menu being the UBOutlet for uisegmentedcontrol but this gives me exception. anyone have some idea? thanks peter 回答1: I would assume that you've called [myArray length] instead of the proper [myArray count] somewhere in your code. NSArray uses the count method, not length for the number of items it contains. 回答2: The right way to do this

Should IBOutlet be weak or strong var? [duplicate]

亡梦爱人 提交于 2019-12-03 02:21:35
This question already has answers here : Should IBOutlets be strong or weak under ARC? (11 answers) I'm using Xcode 6.2 for iOS projects. In older versions of Xcode, when a connection was create for an IBOutlet, it was always weak storage. Now when I create connections, they are defaulted to strong. I leave it that way and don't notice any difference. Which version of Xcode did the default change to strong and why? beryllium Yes, previously outlets should generally be weak but Apple has changed that. Now they recommend to use strong outlets in the WWDC 2015 session Implementing UI Designs in

I can't figure how to fix this Expected identifier or '('

て烟熏妆下的殇ゞ 提交于 2019-12-02 23:28:20
问题 - (IBAction)SignUp:(id)sender; { Expected identifier or '(' IBOutlet UITextField *Firstnamefield; IBOutlet UITextField *Lastnamefield; IBOutlet UITextField *emailfield; IBOutlet UITextField *agefield; IBOutlet UITextField *passwordfield: IBOutlet UITextField *reenterpasswordfield; } 回答1: - (IBAction)SignUp:(id)sender { UITextField *Firstnamefield; UITextField *Lastnamefield; UITextField *emailfield; UITextField *agefield; UITextField *passwordfield; UITextField *reenterpasswordfield; } There

UISegmentedControl deselect (make none of the segments selected)

只谈情不闲聊 提交于 2019-12-02 17:53:00
in fact the title contains my question. I have a UISegmentedControl, and need to deselect currently selected tab. I tried: [menu setSelectedSegmentIndex:-1]; menu being the UBOutlet for uisegmentedcontrol but this gives me exception. anyone have some idea? thanks peter I would assume that you've called [myArray length] instead of the proper [myArray count] somewhere in your code. NSArray uses the count method, not length for the number of items it contains. The right way to do this is: [menu setSelectedSegmentIndex:UISegmentedControlNoSegment]; I guess you try to create a momentary selection

IBOutlet does not display its value in UI

泄露秘密 提交于 2019-12-02 11:44:11
I am building an iOS app using storyboards.I have implemented google maps in my app using swift and rest of the code is in objective C. My scenario: 1.As shown in the diagram, when I click on the label in front of location ( in First view controller ) a modal segue opens a second view controller containing map. 2.In the map view controllers, when the user moves the map with touch, I'm getting address value in a label. ( similar to uber app ) 3.After this , as soon as user presses done button on this controller, it gets back to the first view controller using custom segue and with the value of

Multiple IBOutlets in same line of same type in Swift

无人久伴 提交于 2019-12-02 11:08:45
In objective c you can declare IBOutlets in below mentioned manner: IBOutlet UIButton *btn1, *btn2, *btn3; And you can able to bind these buttons in storyboard. Now I want to use the same terminology in Swift. I want to declare these 3 buttons in same line rather than declaring these in 3 different lines. I can be able to declare these buttons in Swift as well using: @IBOutlet var btn1, btn2, btn3: UIButton! But my problem is I can only able to bind "btn1" in storyboard. "btn2" & "btn3" are not showing up in the Connection Inspector. I don't want to use UIOutletCollection class. You have two

Loading UIViewController from instantiateViewControllerWithIdentifier - nil outlets

柔情痞子 提交于 2019-12-02 08:38:31
I honestly can't understand what am i doing wrong. I have this shared Instance of my UIViewController : static let sharedInstance = UIStoryboard(name:"Main", bundle:nil).instantiateViewControllerWithIdentifier("IAPNEW") as! newIAPClass If i'm presenting it, without accessing it outlets, as so : self.presentViewController(newIAPClass.sharedInstance, animated: true, completion: nil) It's works as expected(show's up). BUT - if i'm trying to access his outlets, it's crashing with "found nil" error : newIAPClass.sharedInstance.lbl_full.text = "mMM" self.presentViewController(newIAPClass