iboutlet

IBOutlet of another view controller is nil

南楼画角 提交于 2019-12-17 16:50:21
问题 I have a storyviewcontroller which has objects on its view. I need to change the text on the UILabel(In the storyviewcontroller) and the load the view on an array. I have connected the IBOutlet to the label in the storyviewcontroller. class StoryViewController: UIViewController { @IBOutlet weak var textLabel: UILabel! @IBOutlet weak var inspiredButton: UIButton! I have created an object of the storyviewcontroller class and am able to access its variables. However, after creating the object of

How to access an IBOutlet from another class

回眸只為那壹抹淺笑 提交于 2019-12-17 15:56:29
问题 I want to know how to access an @IBOutlet declared in a class from another class for example, I have a class named myfirstview class MyFirstView: UIViewController { @IBOutlet var lblred: UILabel! = UILabel() } I want to change the text of the lblred from another class named MySecondView which is written in another .swift file: class MySecondView: UIViewController { func modify() { let mfv = MyFirstView() mfv.lblred.text = "Hello" } } But nothing happens. I have connected lblred with a

IBOutlet and IBAction in Swift

蓝咒 提交于 2019-12-17 13:54:49
问题 I connected a IBOutlet and IBAction to my button variable from Interface Builder to my View Controller. How do I add an action method to the button in Swift? This code doesn't seem to work. @IBOutlet var OK: UIButton! @IBAction func OK(sender: UIButton){} The Objective-C equivalent I found is: @interface Controller { IBOutlet id textField; // links to TextField UI object } - (IBAction)doAction:(id)sender; // e.g. called when button pushed 回答1: When you attach a button to the viewController ,

IBOutlets on second view controller help on swift

允我心安 提交于 2019-12-13 22:12:49
问题 On my first view controller I had no problem creating IBOutlets and Actions, but when I made another view controller, I couldn't make an IBOutlet. There was no blue line when I control dragged it and I couldn't make an IBOutlet and then connect it up either. The first view controller still works. Is it possible to make IBOutlets on two different view controller? 回答1: Your view controller must have a custom class file assigned to it in the identity inspector in InterfaceBuilder: Then select

iOS 7: Cannot connect to IBOutlets, probably because I'm using UITableViewController

独自空忆成欢 提交于 2019-12-13 17:58:09
问题 I cannot create any IBOutlets. I'm using a tableviewcontroller instead of a viewcontroller. When I click on TableViewController, the class is UITableViewController and I can't change that. Here's my code for ViewController.h: // ViewController.h // Tips4 // // Created by Meghan on 1/20/14. // Copyright (c) 2014 Meghan. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> @property (strong, nonatomic) IBOutlet

Identify different iOS devices in coding? [closed]

南楼画角 提交于 2019-12-13 10:37:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I know the in objective-c, there is a way to know which device the user is using. But I really a new of iOS development, I do not know those complex and complicated command in objective-c. Could any one tell me how to identify the phone model by coding. Also, if I can know which device the user is using, is that

How Can I access the textfields in static TableViewcells without creating referencing outlet?

て烟熏妆下的殇ゞ 提交于 2019-12-13 09:39:57
问题 I have lot of text fields statically placed in static TableViewcells. How can access the text in it without creating referencing outlet for each textfield? I have tried taking subviews of cell. It's not working. Any alternatives? I tried this. It's not working. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; for (UIView *subview in [cell subviews]){ if(

Swift NSTimer and IBOutlet Issue

拜拜、爱过 提交于 2019-12-13 05:00:07
问题 I'm using NSTimer to update an image's position on the screen to give the illusion of movement. It's a flappy bird clone I'm creating to learn Swift. Anyway, I'm also updating an outlet by displaying an incrementing Int as the score. However, every time I update the Int and the corresponding outlet, the images on the screen reset to their starting point (bird and tubes). Very odd. Has anyone else come across this? What am I doing wrong? @IBOutlet weak var tube1: UIImageView! @IBOutlet weak

Class is not key value coding compliant

烂漫一生 提交于 2019-12-13 04:24:19
问题 I have a NavigationController , root view controller called "ViewController" and a second view controller called "SettingsViewController". I have a segue to the "SettingsViewController" from "ViewController" which worked until I tried to connect a UITextField called "usernameField" to the "SettingsViewController" by means of Reference Outlet. When I did I got the following error whenever I try to go to the SettingsViewController: *** Terminating app due to uncaught exception

Connecting actions works. Connecting outlets doesn't

你离开我真会死。 提交于 2019-12-13 00:31:11
问题 I have a XIB file with my controls in it, loaded in the Interface Builder (Xcode 4.0.2 on Snow Leopard). The file's owner is set to, let's say, the someClassController class, and I've also added (in the Interface Builder) an NSObject instance of someClass , as well. I've managed to link e.g. a button with an action in someClassController or someClass - and it works for both of them. However , whenever I link an outlet to ANY of them, it fails to show up; and NSLog reports NULL pointers. Hint