viewcontroller

How to present apns token in view controller? [duplicate]

流过昼夜 提交于 2019-12-11 15:18:46
问题 This question already has answers here : How can I convert my device token (NSData) into an NSString? (28 answers) Closed 2 years ago . I don't understand how to present the apns token as a string in view-controller. tried a lot of things and nothings worked out. in swift 4. 回答1: 1. You can save it to UserDefaults as Halil suggested like so: UserDefaults.standard.set(yourAPNSToken, forKey: "APNSToken") And retrieve it inside your ViewController: let token = UserDefaults.standard.string(forKey

How to turn off the automatic swipe to go back in navigation controller? Swift

旧巷老猫 提交于 2019-12-11 14:48:48
问题 I need to turn off the automatic gesture swiping to go back in navigation controller. I using Swift. I have already searched but didn't found a solution for me. 回答1: You can disable the interactivePopGestureRecognizer of your navigationController: self.navigationController?.interactivePopGestureRecognizer.enabled = false 回答2: self.navigationController.interactivePopGestureRecognizer.delegate = self func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer!) -> Bool { return

Get Instance of ViewController from within extension

余生颓废 提交于 2019-12-11 14:12:29
问题 I'd like to get access to a ViewController from an extension and then override a function from a library which should change variables or invoke methods from a specific ViewController (in this case "ViewController"). How can I do that? Or is there a more recommended option? (Hint: I don't want to instantiate a new VC) import PopupDialog class ViewController: UIViewController { //e.g. variable and method to access from extension var score: Int = 0; func startGame(){ ... } } extension

append to array from different class in swift

走远了吗. 提交于 2019-12-11 12:52:07
问题 Im trying to append to my array var feedArray: [AnyObject] = [] from another class. I have 2 classes: class FeedViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { var feedArray: [AnyObject] = [] and class AddEditViewController: UIViewController, NSFetchedResultsControllerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { I want to in my "AddEditViewController" append

present alert view in main view controller (called from subclass)

江枫思渺然 提交于 2019-12-11 10:07:29
问题 I have tow views in my app. A main view(ViewController.swift) and a sidebar(SideBar.swift). If I tapp a button in the sidebar an UIAlertView should be displayed (I call a function in ViewController.swift). But the app crashes because the main view is nil. Do you know how I can fix this? My code in the function (display alert): let alertView = UIAlertController(title: "You need to log in first", message: "To access the special features of the app you need to log in first.", preferredStyle:

Crash after presenting View Controller modal on iPhone

依然范特西╮ 提交于 2019-12-11 10:06:14
问题 I´m trying to implement a Popover for iPad and iPhone. Before iOS 9, there were different ViewController for iPad and iPhone. With iOS9 there should be a possibility to do this with a normal ViewController and different PresentationStyles? (Deployment Target is iOS 9.0) Am i right? according to this post: Stackoverflow answer from Daniel Galasko I tried to implement this answer in objective c. _mediaTypePopoverVC = [[MediaTypePopoverVC alloc] initWithProductId:PRODUCT_ID_NONE_PARENT];

Calling method from viewcontroller to class xcode

随声附和 提交于 2019-12-11 09:52:30
问题 I don't know if it is possible, but I would like to call a view controller's method in a class object. I have method like this in my view controller's .m file: -(void)showLeaderBoard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != nil){ leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; } } I would like to call that method in a SKScene file.

How to change label in ViewController when app enters the foreground

╄→гoц情女王★ 提交于 2019-12-11 09:51:25
问题 i want to change a label in my view controller when the app enters the foreground....: SalaryAppV4AppDelegate.h @interface SalaryAppV4AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { //---------------------------------------------- NSTimeInterval appEnteredBackground; NSTimeInterval appEnteredForeground; NSTimeInterval difference; NSString *times; //----------------------------------------------- SalaryAppV4AppDelegate.m - (void)applicationWillEnterForeground:

ARC - popviewController/DismissViewController

久未见 提交于 2019-12-11 07:19:40
问题 I have some doubts with the ARC. In ARC: When a viewcontroller is dismissed by using the dismissViewController/popViewController, Will it's allocated memory automatically get released? What will happen when there is an asynchronous NSURLConnection is running and before that operation completed, viewcontroller got dismissed? Thank you 回答1: When you dismiss a view controller (or pop it), it will be deallocated if you didn't make any strong pointers to it (that controller is retained by the

How to let drawRect get the value of points from ViewController and draw?

巧了我就是萌 提交于 2019-12-11 04:35:51
问题 I created a class newView from UIView and aim to draw a quadrangle. the 4 coners (ClipPointA, ClipPointB, ClipPointC, ClipPointD) of the quadrangle are supposed to read value from ViewController. newView.h: @interface newView : UIView { CGPoint ClipPointA, ClipPointB, ClipPointC, ClipPointD; } @end newView.m: @implementation newView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code. } return self; } - (void)drawRect:(CGRect)rect { //