ImagePicker causes reload of UIViewController - ios

I am using iOS 8 storyboard with auto layouts. I have objects that are hidden UIViews to start and end up being visible. Whenever I go pick a video from my UIImagePicker and come back, all the objects turn hidden again almost like the UIViewController is being reloaded. How can I fix this? How do I stop the UIViewController from auto reloading every time another controller is shown like in this case a UIImagePicker.

Do you perform any view related show/hide inside viewWill/DidAppear/Disappear or viewDid/WillLayoutSubviews?

Related

When to use UIViewController vs UIView when animating?

When should a UIView be placed over the current views (in the same controller) vs adding a whole new UIViewController?
I know that the UIViewController manages UIViews, but imagine that you wanted something to popup when a user selected something. What decides whether a UIView be animated and added to the current controller (using animateWithDuration), or a new UIViewController with a custom transition?
Twitter example:
http://i.giphy.com/3o7TKKcmcIz76ONXFe.gif - Not sure if this is a UIView added to the existing controller, or if it's a new controller. I just tap the image, and it pops up. I then slide down and slowly move the image off the screen (interactively).
Spotify examples:
http://i.giphy.com/3oz8xRSkmxbcVqPZf2.gif - Probably a UIViewController. I'm grabbing the bottom bar and sliding it up. I then slide down on the album cover.
http://i.giphy.com/3oriO7SjzB5GfThx60.gif - Possibly a UIView? Happens when I press and hold a album cover.
What determines when one should be used over the other? It would probably be helpful if you explained the examples. Thanks.

Passing through Segues, Determining what view the user is on and NavigationController buttons not appearing

Sorry for the long and possibly confusing question. In this I have 2 main problems with my code, those being: 1- When I embed my viewControllers in a UINavigationController and add a bar button item, nothing appears, yet it appears when I add it to the pageViewController. Secondly, I am wondering if there is a way to do this differently and use one button on the pageView (which appears on all viewcontrollers in it) and just determine what the user was looking at when they pressed the button and are taken to another viewcontroller.
I am trying to build a page-based application, and I have set up the application with 7 view controllers (One for each day of the week). I then have an AddViewController, where users can add data to a certain day. I was wondering if there is a way to only use 1 addView linked to the NavBar on the PageViewController, as when I embed all other viewControllers and add a bar button, it does not show up.
With the pageViewController being embedded, this is what it looks like with a bar button on it.
This then leads to:
Which works well, however I am wanting to pass data to various arrays (one for each viewController), and I want to know which ViewController the user wishes to add to (based off what day they were on). Is there a way to determine this and then unwind to the viewController and append the right data to the right array or should I have one addView per dayViewController? If that is the case, I am coming across the issue whereby the bar button items do not appear on the viewControllers when they are embedded in a navigationController. It looks like this:
StoryBoard: (Example: MondayViewController)
The outcome is a missing barButton: (Keep in mind I changed the tint Colour to white so it would be visible)
I was wondering if anyone has the answer to either of my problems, and once again, thanks for taking the time to look at this array of questions in one problem.
Any suggestions are welcome !
Rowan,
You can do this:
Create an UINavigationViewController and then embed an UIPageViewController in it.
In the data source for the UIPageViewController implement these two methods:
- pageViewController:viewControllerBeforeViewController:
- pageViewController:viewControllerAfterViewController:
Here you will return the correct instance of your DayViewController for each position (or nil if you are on the first/last page). Your data model would also be set here.
Add your "Add" bar button to the navigation bar of the UIPageViewController and let it push your AddViewController. When pushing the AddViewController provide to it the info on which day is currently visible. You will probably need to keep track of this your self. Use the - pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted: method of the UIPageViewController delegate.

Implementing A Mail app-like User Interface

I am trying to implement a user interface that is similar to the iPhone's Mail app.
The main screen displays a table. From the table the user can select a cell, at which point the next screen is launched. At the bottom, there is a bar showing a short text and an icon.
The second screen displays the details of the cell. It will also be a table display. The bottom bar shows icons associated to this screen.
What kind of layouts do I use to implement this in Xcode?
1. Do I use a View controller, add a View and embed a TableView and a Toolbar inside that view?
2. Do I use a Table View Controller and add a Table View inside it and use the bottom tool bar that comes with the table view?
In the Table View Programming Guide for iOS, under 'Recommendations for Creating and Configuring Table Views,' it says 'Use an instance of a subclass of UITableViewController to create and manage a table view.' When I use this, the bottom bar can only be fixed or disappear when going back and forth between two screens via segue. That makes me wonder whether I should just use a View controller which is against the recommendation.
Use a UIViewController
Why?
If you are going to display more than a tableView then it is recommended to use a UIViewController for the storyboard.
UIViewController are much more flexible. I guess your confusion comes from the following documentation line:
Use an instance of a subclass of UITableViewController to create and
manage a table view
This does not mean you must to drag and drop a UITableViewController on the storyboard. It means your class need to inherit from UITableViewController or at least implement the deleguate and datasource methods.
You would use UITableViewController only and only if you need to display a tableView.

How to add centered UIActivityIndicator for UICollectionView when using UICollectionViewController?

I'v never used UITableViewControllers or UICollectionViewControllers, because you can have the same functionality by using UIViewController with its root UIView, then adding UITableView in xib or storyboard and assigning its delegate and datasource. And I also was able to put activity indicator inside the center of root UIView.
Now the things get a little bit complicated when using UICollectionViewController where its root view is UICollectionView. I need to update some code of other guys and they put activity indicator inside UICollectionView (in storyboard). The problem is this activity indicator gets hidden when cells are reused because activity indicator view is the most bottom one. I was unable to change visibility priority storyboard and also this code in view didLoad is not working:
[self.itemsCollectionView bringSubviewToFront:self.activityIndicator];
Because labels, images and etc. views of collection view cell are placed later, during collectionView:cellForItemAtIndexPath:. I could try to call bringSubviewToFront: in collectionView:cellForItemAtIndexPath: but that would be a wrong decision. Any ideas how to achieve this when using UITableViewControllers or UICollectionViewControllers?
IMHO the only reason to use UITableViewControllers or UICollectionViewControllers is because static cells are not shown storyboards when designing layout.
UPDATE It appears iOS wraps UICollectionView inside UICollectionViewControllerWrapperView. Tried to add activity to this wrapper view in viewWillAppear:
[self.itemsCollectionView.superview addSubview:self.activityIndicator];
But with no luck - activity indicator is still is below the cells.
I'v ended in refactoring existing UICollectionViewController in storyboards: I'v opened storyboard xml file with TextEdit, searched for the screen and changed its type from collectionViewController to viewController because was unable to find another way how to change the type of controller, though I hope there will appear some more elegant way for that in the nearest future. Then, I'v wrapped collectionView inside root view and placed activityIndicator inside this view. It's proven classical approach that works like a charm.

uitableview in uiviewcontroller disappears in xcode 5

I am building an ios application for iPad, I used uitabbar to show some uiviewcontrollers, I added in some of these uiviewcontrollers an uitableview. Now when I first load the application the uitableview appears and show my data. if I opened an uiviewcontroller that is not in the uitabbar and return to the tab bar the table disappears !!! then if I choose another tab from uitabbar tabs and return to my tab (the one which has the uitable that disappears) the table show up !!! anyone know how can I fix this problem ?
I think it is an Storyboard/layout issue !!
any help will be appreciated, thanks
Sounds to me like you are doing some kind of initialization in viewDidLoad which is not called again when you come back from a child view controller.
One quick fix could be to move that code to viewDidAppear method. If you further want to understand when either of this method was called or not, you could throw in some NSLog statements in each.

Resources