iboutlet

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

时光毁灭记忆、已成空白 提交于 2019-12-10 01:56:34
问题 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

how can i access IBOutlet in another class? in swift

社会主义新天地 提交于 2019-12-09 23:20:29
问题 I'm sorry i have bad eng skill. i want access IBOutlet in another class. i found many question in stackoverflow, but all answer not working in my code firstly this is my code. ViewController.swift import UIKit class ViewController: UIViewController { @IBOutlet var MainViewController: UIView! = nil @IBOutlet var LyricsViewController: UIView! = nil @IBOutlet var ListViewController: UIView! = nil override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,

Can I connect multiple objects with different tags to the same IBOutlet?

偶尔善良 提交于 2019-12-09 17:28:05
问题 I have 30 buttons in one view in Interface Builder. Each has a different tag between 100001 and 100030. I've found it easy to use the same action for each button, passing along the tag for each one when pressed and using code to decide which level to load. I want to connect all the buttons to a single IBOutlet, but have each button load a different image based on the user's saved data and the button's tag. How do I do this? 回答1: Use IBOutletCollection to add an outlet collection to your view

IBOutlets and IBactions require ! in the end

浪子不回头ぞ 提交于 2019-12-09 06:04:23
问题 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

How to make IBOutlets out of an array of objects?

佐手、 提交于 2019-12-08 23:20:45
问题 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. 回答1: It is possible, it’s called outlet collection . This is the way to define an outlet collection: @property(retain) IBOutletCollection(UIImageView) NSArray *images;

ViewController's outlet view first non-nil, then nil when loading from bundle

假装没事ソ 提交于 2019-12-08 19:59:06
问题 I am loading a UIViewController from a bundle with initWithNibName:bundle: . If I set a breakpoint in its viewDidLoad I can see that its view is set. I can also see this when viewing About.xib in the Interface Builder. However once the view is actually used for the first time (in a call to [self.navigationController pushViewController:viewController animated:YES] according to my app's logic) I get this error: * Terminating app due to uncaught exception 'NSInternalInconsistencyException',

using IBOutlet from another class in swift

回眸只為那壹抹淺笑 提交于 2019-12-07 14:58:42
问题 I have an IBOutlet in ViewController.swift called backgroundView class ViewController: UIViewController, SideBarDelegate { @IBOutlet weak var backgroundView: UIView! And I want to use that IBOutlet on SideBar.swift @objc protocol SideBarDelegate{ func sideBarDidSelectButtonAtIndex(index:Int) optional func sideBarWillClose() optional func sideBarWillOpen() } //When an item of the sidebar is selected, and also when the sidebar will open or close class SideBar: NSObject,

Launch screen is black when set to a storyboard file

做~自己de王妃 提交于 2019-12-07 10:47:10
问题 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.) 回答1: The problem in this case was that there was an outlet set on the view controller . If there

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

自闭症网瘾萝莉.ら 提交于 2019-12-06 16:48:13
问题 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,

IBOutlet isn't connected in awakeFromNib

假如想象 提交于 2019-12-06 16:40:29
问题 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;