viewdidload

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

前提是你 提交于 2019-12-25 07:12:56
问题 I'm receiving this error when I am using an attached long press gesture to get a modal view to come up using the following code: // Long press to go to settings for one - (void)longPressOne:(UILongPressGestureRecognizer*)gesture { [self performSegueWithIdentifier:@"buttonOne" sender:self]; } // Long press to go to settings for two - (void)longPressTwo:(UILongPressGestureRecognizer*)gesture { [self performSegueWithIdentifier:@"buttonTwo" sender:self]; } - (void)viewDidLoad { // Add gesture to

Problem with ViewDidLoad method

匆匆过客 提交于 2019-12-25 05:12:22
问题 I have a problem with the methoed ViewDidLoad... At the start, my application must run some code but if I load one other viewController and than I return in the main Controller the application runs again the code! I want that my app runs this code at the start but when the user returns to the main view the app does anythings! 回答1: You could put the code you need executed in the Application Delegate and just run it at startup from there. In your project, you should have a pair of files and

Save UIButton state and load with NSUserDefaults

我的梦境 提交于 2019-12-25 03:55:31
问题 I was wondering how to detect whether the button was hidden or not, and how much alpha was applied to it. Then, when viewDidLoad is called, these values can be applied to make the buttons the same state they were left in when the application closed. How can I code this? Thanks, James 回答1: If, as your title suggests, you want to use NSUserDefaults , then you can set them like this: -(void)saveButtonState:(UIButton*)button { NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];

UITableView takes much longer to load when numberOfRows returns a large number

余生长醉 提交于 2019-12-24 05:46:22
问题 Why does UITableView take more time to load when the number of rows is large? What is it that takes time between viewDidLoad and the first cellForRowAtIndexPath function call? These are the log statements when numberOfRows returns 100,000 (notice the time (5 seconds delay)): 2014-02-05 20:51:22.806 TableViewTest[3995:60b] View Did Load 2014-02-05 20:51:27.526 TableViewTest[3995:60b] Cell for row at indexpath.row: 0 These are the log statements when numberOfRows returns 10,000 (notice the time

with “viewDidLoad” my viewController take much time to appear!

二次信任 提交于 2019-12-24 01:25:13
问题 when i load my viewController i used "viewDidLoad"method to init my view ,but this take much time to make the view appeared .So i had the idea to use "viewDidAppear" method to accelerate the appearance of my view but the load of the informations about my view are now loaded to the memory every time that i push my view (which is normal) or i pop to it(and there is my problem) Have you an idea? 回答1: Create a background task that is started in viewDidLoad and just updates the GUI when it's

Does it make a difference where to put [super viewDidLoad] in my UIViewController? [duplicate]

早过忘川 提交于 2019-12-24 00:44:11
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: [super viewDidLoad] convention Does it make a difference where I put [super viewDidLoad] within the viewDidLoad in my UIViewController? I.e., should it go at the beginning (before my code to set up the UIViewController) or the end )after my code to set up the UIViewController) of the method, or does it not make any difference? 回答1: You should usually call super as early as possible. Otherwise, the superclass may

UITableView: load all cells

一曲冷凌霜 提交于 2019-12-23 18:21:18
问题 Is it possible to load all cells of an UITableView when the view is loaded so that they are not loaded when I'm scrolling? (I would show a loading screen while doing this) Please, it's the only way at my project (sorry too complicate to explain why ^^) EDIT: Okay let me explain you, what I'm definite doing: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = [NSString stringWithFormat:@"Identifier %i/%i",

ViewDidLoad not called when adding to Container View

拈花ヽ惹草 提交于 2019-12-23 12:08:27
问题 I have a container view set up in my storyboard file but I want to embed the view controller programatically after setting some properties. This is my code in the parent VC's viewDidLoad: _workoutVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"entryTableVC"]; _workoutView = _workoutVC.tableView; [self addChildViewController:_workoutVC]; [_workoutVC.tableView setFrame:_container.bounds]; [_container addSubview:_workoutView]; However,

Set UITabBarItem title programmatically?

拈花ヽ惹草 提交于 2019-12-22 05:23:17
问题 My app is based on a tab bar architecture. In order to have an easy internationalisation mechanic, I do not write any string in XIB files. viewdidload permits to change programmaticaly the strings in the views. When my app launches, I can see the 4 tabs. But in fact only the first one loads its view controller. The others wait for user click to be loaded. Tabs title can be changed using [self setTitle:@"Mouhahaha"]; in viewDidLoad of loaded view controller. If I want to keep my

Swift/iOS: IBOutlet nil after loading view controller

谁都会走 提交于 2019-12-21 04:27:31
问题 I'm building an app (in XCode 8.2.1) where some objects are displayed on a 2D board, and when the user taps one of these objects some info should be displayed about it as a styled modal info box. My design is to have the info written in a separate view controller, which I would display when needed. I've designed a basic stub for the second view controller and added a single label to it in the interface builder. Then I've ctrl-linked this label to my custom VC class: class InfoViewController: