dzenbot / DZNPhotoPickerController

A photo search/picker for iOS using popular image providers like 500px, Flickr, Instagram, Giphy, Google & Bing Images
https://www.cocoacontrols.com/controls/dznphotopickercontroller
MIT License
1.51k stars 266 forks source link

Search bar keeps moving down after search #109

Closed ryderjack closed 8 years ago

ryderjack commented 8 years ago

After every search the search bar in the picker controller moves down, see image:

simulator screen shot 4 apr 2016 11 29 16

Running on iOS 9.3, installed via CocoaPods

dzenbot commented 8 years ago

What version of the lib are you using?

ryderjack commented 8 years ago

Latest via Coacopods

krazeeKoder commented 8 years ago

I have this same issue

jasonbodie commented 8 years ago

I'm also experiencing the same issue.

jarrillaga commented 8 years ago

Hi Mates, How did you fix this issue ?

jarrillaga commented 8 years ago

Nobody ?

ryderjack commented 8 years ago

I got rid of the search bar and used insets to move the collection view up

dzenbot commented 8 years ago

You know, you can always look at the implementation and try to fix it and submit a PR. That's the whole point of open source: collaboration.

jarrillaga commented 8 years ago

I know, I am trying but I don´t realize how to fix it. The problem is only when you have a one search option and the scope tabs don´t appear. Ryderjack can you give any detail please ?

jarrillaga commented 8 years ago

@dzenbot Do you have any idea? I could try to fix it if you help me.

dzenbot commented 8 years ago

My first though is that the main view controller uses a few static height values. For example: https://github.com/dzenbot/DZNPhotoPickerController/blob/master/Source/Classes/Core/DZNPhotoDisplayViewController.m#L147

Perhaps, these values should be dynamic instead.

jarrillaga commented 8 years ago

@dzenbot Hi ! Thanks for your answer. I don´t think the problem is layoutFittingSize function because the shifting occurs after the SearchBar loses the focus and this function is not executed at this point. My thought is that something changes in iOS 8 with the navigationbar but I have been trying all the afternoon and I can´t fix it yet.

dzenbot commented 8 years ago

Does this happen on iOS 9?

jarrillaga commented 8 years ago

@dzenbot Yes, I am in iOS 9 trying the search with only Flicker. Try it in your example, put only one image provider.

dzenbot commented 8 years ago

Why would you mention iOS 8 then? Please, give it a try. Debug. We're all developers. If this is a huge concern on your product, spend the time to do the tweak.

jarrillaga commented 8 years ago

@dzenbot I am debugging it, in case I can fix it I will submit the fix but my problem now is that i´m lost. I appreciate your work. In case you realize what is happening please let me know. Thanks man ! :)

jarrillaga commented 8 years ago

Ok, I just found the solution. The problem of the shifting is when you set only one search provider (ie: Flicker). The cause of it is that in the method - (UISearchController *)searchController of DZNPhotoDisplayViewController.m, the scopeButtonTitles is set with an array of only one element and the framework has to deal with it and it doesn´t know how. The scope buttons must be set with an array of more than one element. So the solution is:

    if([[self segmentedControlTitles] count]>1)
    {
        searchBar.scopeButtonTitles = [self segmentedControlTitles];
    }
    else
    {
        searchBar.scopeButtonTitles = nil;
    }

I hope it works for you and you fix the code in order to avoid this error in the future.

dzenbot commented 8 years ago

That solution makes a lot of sense. Would you be so kind to submit a Pull Request with the fix?

jarrillaga commented 8 years ago

@dzenbot There is only a branch, I don´t know how to do the pull request.

jasonbodie commented 8 years ago

@dzenbot I just put up a pull request #114. And double checked it in my app. Thanks @jarrillaga