viewcontroller

Swift: Reload a View Controller

限于喜欢 提交于 2019-12-21 03:10:45
问题 I need to refresh a view controller when a certain button is tapped. Simply activating viewDidLoad() does not seem to be working for what I need to do. However, when I leave the view controller then come back to it, it seems to work perfectly? How can I refresh/reload a view controller as if I have left it then come back to it without ever actually leaving it? 回答1: Whatever code you are writing in viewDidLoad , Add that in viewWillappear() . This will solve your problem. 回答2: You shouldn't

iPhone - designing my own viewController transition

ぃ、小莉子 提交于 2019-12-20 09:07:35
问题 My app have a bunch of viewControllers and I am trying to design my own animation transition from one viewController to the other. I have found this - (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion but this does not appear to allow designing my own

How do I create a view controller file after creating a new view controller?

余生长醉 提交于 2019-12-20 08:23:13
问题 I am developing a tabbed application. When I create a new view controller and link it to the tab bar controller, unlike the other two default view controllers, this one has no viewcontroller.swift file. How can I create this file? I am using Xcode 6 and developing the app in Swift. 回答1: Correct, when you drag a view controller object onto your storyboard in order to create a new scene, it doesn't automatically make the new class for you, too. Having added a new view controller scene to your

Same view controller loads twice

喜夏-厌秋 提交于 2019-12-20 05:01:19
问题 I've read several posts on this issue but none of them solved my problem. I'm coding an app where I have to click on a button ("Prepare") to go to the following ViewController. When the button is clicked, it also passes data between the two view controller. The problem is, when I click the button, the following ViewController loads twice. Thus, if I want to go back I have to go back through two same ViewController. I've checked the segue, the class names and files names but nothing fixes it.

How to “restart” application ios

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 04:59:42
问题 So I have an app where a user goes through 3 view controllers and then submits a picture to Facebook. After they submit it to Facebook, I want them to be able to choose to restart the process over again, as if they had re-launched the app. How could I do this? thanks 回答1: OK, because you haven't been clear about your navigation patterns, I'll show the two kinds of transitions and their opposites: Push-Pop : Is created by pushing a new UIViewController onto the navigation stack using [self

Cannot call value of non-function type 'String'

萝らか妹 提交于 2019-12-19 12:23:24
问题 I'm trying to pass the ILTItem variable into my ILTViewController, triggered by AppDelegate.swift when the user launches my app via a deeplink. The code I have errors with: Cannot call value of non-function type 'String' on the line where I define ilt . Here's the code I have at the moment: let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate var ilt = ILT(homeworkID: 1234, title: "History ILT", subject: "History", teacher: "Miss A Smith", teacherCode: "asmith",

When/How - Outlet -> didSet

孤者浪人 提交于 2019-12-18 18:23:49
问题 I'm wondering, when/how does the didSet on an outlet actually trigger? For example : @IBOutlet weak var modifyButton: UIButton! { didSet { modifyButton.layer.cornerRadius = 9 } } 回答1: Outlet properties initialized as nil when class just initialized. They will have values later, when objects will be initialized from nib. First step, when you can be sure that all properly configured outlet properties have nonnil values is viewDidLoad . So, didSet observer on this properties will be called just

Swift: How to access in AppDelegate variable from the View controller?

爷,独闯天下 提交于 2019-12-18 12:15:34
问题 I would like to write in the text or csv (prefer) file the variable from the view controller. Indeed I am doing a drawing app and I would like to write in the file the current position of the finger. class ViewController: UIViewController {var lastPoint = CGPoint.zeroPoint ... } I would like to have access to lastPoint.x and lastPoint.y from the AppDelegate. how I could do that ? Thank you. 回答1: Your question is full of confusion but if that's what you are looking for: You can access the

Swift performSegueWithIdentifier shows black screen

本小妞迷上赌 提交于 2019-12-18 09:44:16
问题 I have read through a lot of different posts regarding this issue, but none of the solutions seemed to work for me. I started a new app and I placed the initial ViewController inside a navigation controller. I created a second view and linked them together on the storyboard with a segue. The segue works successfully, and I can see the data I am transferring in a print statement from the second screen, but the screen shows black. WelcomeScreen: override func prepareForSegue(segue:

Changing viewController on Button Click

僤鯓⒐⒋嵵緔 提交于 2019-12-18 07:11:56
问题 I am new to iPhone programming. what I am trying is I have one screen with a button. And I want to change the view controller not only the view when I click that button (I know how to add subview) because from that 2nd view controler, I have to go to the third view which is not possible if I add subview in first place. Can anybody please help me with that? Is this possible? and if yes, how? All the views and view controller are created programmaticaly. I am not using IB. EDIT: here is the