I'm trying to place a scrollview such as the top of the view will be right below the navigation bar. I noticed that I have 2 different behavior on ios 10 and 11+.
On the image below, ios10 is on the right.
Here's a link to the code: https://github.com/floriel-fedry-cko/ios-scrollview.
Is there a way to fix it to have the same behavior on both?
Set Navigation Bar's translucent property to false. You can set it in code and storyboard both.
self.navigationController?.navigationBar.isTranslucent = false
you can do like this code
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.isTranslucent = false
}
Related
I searched lot on internet to find a solution for my problem but I haven't found a answer. I hope someone can help me.
I have a Android application where I made a fragment with 3 tabs. Every tab had a different layout and in every layout there is a listview with different id. The problem is that, when i click on item of listview, only the item of the first tab take focus and background was set to green. In the other tabs the item is selected but focus don't change the background item color.
I had clear the focus on the first tab if was selected but this don't resolve the problem.
this is the code that I implementer on tab
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View view,
int pos, long arg3) {
view.setSelected(true);
selectedBusiness = businessList.get(pos);
buttonModify.setEnabled(true);
}
});
Any idea?
Thank Max
I found the solution.
The error in my case was made from
ArrayAdapter adapter = new ArrayAdapter(getActivity(), R.layout.my_business_item);
I don't know why but the problem was the layout. In the other two tabs, I used the adapter with another layout android.R.layout.simple_list_item_1. With this layout the focus dosen't work. With my simple layout it works.
I have two ViewControllers - the main one is Portrait only - the second, which displays a WebView loaded with a YouTube video can rotate to any orientation. When it is dismissed in Landscape, returning to the main ViewController, the status bar is left in Landscape mode. I know when the YouTube view is dismissed and have placed the following line on code in the called method:
UIApplication.SharedApplication.SetStatusBarOrientation(UIInterfaceOrientation.Portrait,true);
But it has no effect on the status bar. Is there some other place to set the orientation? Other ideas?
Thanks,
Rick
Fixed the problem by adding the following to the AppDelegate
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations (UIApplication application, UIWindow forWindow)
{
return UIInterfaceOrientationMask.AllButUpsideDown;
}
Then this code actually did what it is supposed to:
UIApplication.SharedApplication.SetStatusBarOrientation(UIInterfaceOrientation.Portrait,true);
I have a scroll view, and when a user moves from one imageview to the next, I want the title in the navigation bar to change. So I want to set a new title for the navigation bar for each image in the scroll view. How would I go about doing this?
Thank you very much for your help.
Write a delegate for your scroll view. In the delegate, implement the scrollViewDidScroll: method to figure out which image is currently visible and change the title.
To eliminate your incompatible type warning, you can declare that ScrollViewController adopts the UIScrollViewDelegate protocol:
#interface ScrollViewController : UIViewController <UIScrollViewDelegate>
I have a ViewController with a UIWebView, in a Objective-c project for iPad.
When I add html (with loadHtmlString), I try to keep the scroll position it had before the loadHtml, but I cannot help and it returns to the top.
Here are the lines I use:
scrollPosition = [[webView stringByEvaluatingJavaScriptFromString: #"scrollY"] intValue];
[webView loadHTMLString:html baseURL:nil];
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:#"window.scrollTo(0, %d);",scrollPosition]];
I tested the value 'scrollY' at different locations in my code
and it stays at the value scrollPosition that I want, but when it ends up showing on the screen the WebView is always at the top (with the scrollY value then to 0).
Is there someone who could help me figure out why this happens?
I checked for hours the answers online, also on StackOverflow.
I tried different solutions (like adding in my webview the JavaScript "onclick="scroll(); return false;", but to no avail.
I tried to self-delegate the webView and update the scrollTo in webViewDidFinishLoad, but it seems that webViewDidFinishLoad is not called (the breakpoint is not reached) although I did add in .h in the interface and in the .m in ViewDidLoad the line: webView.delegate=self;
Thank you in advance for any help.
I realized that after recompiling, webViewDidFinishLoad was called after the html was updated, and that I could then scroll to the correct position.
For the self delegation I used in viewDidLoad, it looks so:
webview.delegate = self;
Before updating the html in the webView I calculate the scrolling position with the code:
scrollPosition = [[wbView stringByEvaluatingJavaScriptFromString: #"scrollY"] intValue];
Then, for moving back to this position once the webView has an updated html, I then use:
-(void) webViewDidFinishLoad:(UIWebView *)wbView {
[wbView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:#"window.scrollTo(0, %d);",scrollPosition]];
}
I found part of the solution through the post below, with the answer of Pawel:
How can I scroll programmatically to the bottom in a uiwebview
I have an application made by a UITabBar with three tabs. One of these is a UIViewController in which I implemented the willRotateToInterfaceOrientation to change the orientation and position of my views.
Everything works except when that view is not the currently shown. In that case willRotateToInterfaceOrientation is not invoked and my views are not set. Which is the best place where to set the new positions and sizes of those views when that tab is not the shown one? How would you implement this?
Thanks!
Just in case anyone else need this, I solved simply by setting the frames in the viewWillAppear method of the UIViewController, in case the orientation has changed.