presentviewcontroller

iOS: present view controller programmatically

不羁岁月 提交于 2019-11-27 00:14:28
问题 I'm using the presentViewController:animated:completion: method to go to another view controller. This is my code: AddTaskViewController *add = [[AddTaskViewController alloc] init]; [self presentViewController:add animated:YES completion:nil]; This code goes to the other UIViewController but the other controller is empty. I've always been using storyboards but now I need this to be done in code. 回答1: If you're using a storyboard, you probably shouldn't be using alloc and init to create a new

iOS 10 error [access] <private> when using UIImagePickerController

三世轮回 提交于 2019-11-26 23:46:34
I am using XCode 8 and testing with iOS 10.2 Beta. I have added the Photos, PhotosUI and MobileCoreServices frameworks to project. Very simple code: #import <Photos/Photos.h> #import <PhotosUI/PhotosUI.h> #import <MobileCoreServices/MobileCoreServices.h> @interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, PHLivePhotoViewDelegate> @property (strong, nonatomic) IBOutlet UIImageView *imageview; @end and implementation: - (IBAction)grab:(UIButton *)sender{ UIImagePickerController *picker = [[UIImagePickerController alloc]init]; picker

Present a modal view controller with transparent background

我的梦境 提交于 2019-11-26 18:20:28
问题 I want to present a UIViewController programmatically which should show up (or not, rather) with transparent background. I want it for iOS 7.0 and above. I've find myself many questions (and answers) but they weren't able to help me. Here's the view hierarchy of my app. I'm using a side menu controller (RESideMenu). I have a rootView (base from RESideMenu) -> Showing a Center controller (along with a left view controller) in UINavigationController . In requirements, I'd like to present a view

How to call a View Controller programmatically?

情到浓时终转凉″ 提交于 2019-11-26 15:17:28
问题 I have looked at all the tutorials I can find on this one, and I still don't have the answer. I need to call another view from the code. I am using UIStoryboards . I have changed the view many times by control-dragging from UIButtons , but now it must be from the code. I am trying to call the info page from the main menu if it is the first time the user has opened the app. I cannot seem to find a way to change the views from the code, however. All my views are controlled by the same files (

Swift presentViewController

谁说胖子不能爱 提交于 2019-11-26 11:59:08
问题 I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to another viewcontroller.swift file (We will call it view2.swift ) and have it be part of a function that a button calls? I have tried the following: let storyboard: UIStoryboard = UIStoryboard(name: \"myTabBarName\", bundle: nil) let vc: UIViewController = storyboard.instantiateViewControllerWithIdentifier(\"myVCID\") as

Warning: Attempt to present * on * whose view is not in the window hierarchy - swift

混江龙づ霸主 提交于 2019-11-26 10:20:27
问题 I\'m trying to present a ViewController if there is any saved data in the data model. But I get the following error: Warning: Attempt to present * on *whose view is not in the window hierarchy\" Relevant code: override func viewDidLoad() { super.viewDidLoad() loginButton.backgroundColor = UIColor.orangeColor() var request = NSFetchRequest(entityName: \"UserData\") request.returnsObjectsAsFaults = false var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) var

iOS 10 error [access] <private> when using UIImagePickerController

这一生的挚爱 提交于 2019-11-26 08:47:24
问题 I am using XCode 8 and testing with iOS 10.2 Beta. I have added the Photos, PhotosUI and MobileCoreServices frameworks to project. Very simple code: #import <Photos/Photos.h> #import <PhotosUI/PhotosUI.h> #import <MobileCoreServices/MobileCoreServices.h> @interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, PHLivePhotoViewDelegate> @property (strong, nonatomic) IBOutlet UIImageView *imageview; @end and implementation: - (IBAction)grab: