viewcontroller

dismiss share extension custom viewcontroller

*爱你&永不变心* 提交于 2019-12-01 01:44:35
问题 I am trying to create a custom view controller to be used with a share extension. Everything works, but I don't know how to dismiss the custom view controller. Basically I launch my share extension from safari and want to completely dismiss this and return back to the safari view. I know this should not be hard, but I am new to share extensions. Below is my base code. Thanks. Bob // // ShareViewController.swift // ShareExtension import UIKit import Social import MobileCoreServices class

When/How - Outlet -> didSet

♀尐吖头ヾ 提交于 2019-12-01 01:39:12
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 } } 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 before viewDidLoad . Because all of this you need to be careful with outlet properties: for example you will

iOS Swift, returning to the same instance of a view controller

末鹿安然 提交于 2019-12-01 01:08:55
I have a problem, where I have two view controllers A and B. View controller B has a map, with a route draw on it. I can move back and forwards between the two view controllers at the moment, but the B view controller is reset every time it loads. I think this is because I am using segues and it is creating a new instance of a View controller every time. I have tried using the following code to solve this issue, but it is still not working. The views load correctly, but view controller B is still being reset @IBAction func mapButton(sender: AnyObject){ let storyboard = UIStoryboard(name:

switching view controllers using swipe gestures

99封情书 提交于 2019-11-30 20:06:35
Okay so here is the problem I'm running into: I am attempting to switch from one viewController that I named MenuViewController which contains my menu (obviously). I have a separate viewController named ViewController that contains my mapView . I would like to be able to double finger swipe left from my MenuViewController over to my mapView . I'm not exactly sure where to start. Also, I am using xib files, and not the storyboard. Running iOS 6. UISwipeGestureRecognizer *swipeLeftGesture=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; [self.view

iOS Swift, returning to the same instance of a view controller

霸气de小男生 提交于 2019-11-30 19:06:56
问题 I have a problem, where I have two view controllers A and B. View controller B has a map, with a route draw on it. I can move back and forwards between the two view controllers at the moment, but the B view controller is reset every time it loads. I think this is because I am using segues and it is creating a new instance of a View controller every time. I have tried using the following code to solve this issue, but it is still not working. The views load correctly, but view controller B is

Swift 3, Xcode 8 Instantiate View Controller is not working

痴心易碎 提交于 2019-11-30 18:02:57
Xcode 8 when it compiles says to change instantiate viewcontroller with identifier to simply, instantiate view controller. I did that, why does it give two errors? I'm working with Swift 3. I want to change pages programmatically.I've read a lot of other questions on the topic. All of them use instantiate view controller with the identifier. They haven't adopted the new language. @IBAction func switchPage(_ sender: UIButton) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let viewController = storyboard.instantiateViewController("secondViewController") as! UIViewController self

Swift 3, Xcode 8 Instantiate View Controller is not working

喜夏-厌秋 提交于 2019-11-30 16:38:20
问题 Xcode 8 when it compiles says to change instantiate viewcontroller with identifier to simply, instantiate view controller. I did that, why does it give two errors? I'm working with Swift 3. I want to change pages programmatically.I've read a lot of other questions on the topic. All of them use instantiate view controller with the identifier. They haven't adopted the new language. @IBAction func switchPage(_ sender: UIButton) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let

How to pop back to specify viewController from navigationController(viewControllers/stack)?

雨燕双飞 提交于 2019-11-30 16:09:42
问题 I've created an application with serial views (A,B,C,D,...), and I need to pop back D to B. Someone may say Why not using: [self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:1] animated:YES]; However, it is not a good solution. Because this method needs you to get the index which our "B" is store in. Question : How to get the index of "B" in the viewControllers? format in the UIViewControllers should be: "< A: 0x6e70710 >", "< C:

Swift passing calculated data back to previous view controller

北城余情 提交于 2019-11-30 15:39:02
问题 I am creating my first simple budgeting app. Basically, I take a few user inputs like monthly income & savings goal. Then they click "start", & the app calculates stuff such as, their daily budget etc. Here I'm running into trouble. After all the calculations, I display "how much you can spend each day" (e.g. $20 a day), which I pass forward through segues from their original inputs on the original screen. Now, in this VC ( UserInfoVC ) I created a button which lets them add how much money

Swift passing calculated data back to previous view controller

不问归期 提交于 2019-11-30 15:07:02
I am creating my first simple budgeting app. Basically, I take a few user inputs like monthly income & savings goal. Then they click "start", & the app calculates stuff such as, their daily budget etc. Here I'm running into trouble. After all the calculations, I display "how much you can spend each day" (e.g. $20 a day), which I pass forward through segues from their original inputs on the original screen. Now, in this VC ( UserInfoVC ) I created a button which lets them add how much money they spent today. So when they click this "add money spent" button, I open a new VC ( AddSubtractMoney )