When WKWebView embed in a UITableViewCell, secondHalf of WebView will not display - ios

This is very strange. I embed a WKWebView into the first cell(IndexPath.row = 0)of a UITableView . and if the webView's content is short ,it works fine.But when I put more text and image in the webView .the bottom part of the webView is not display. I have check the UI layer:
And I found the most upper layer(WKCompositingView) 's height is not right. the second layer is WKCompositingView too.
I don't know why,Buy if I put the WebView into a controller's view it worked fine.
Another point is , if I called a UITextFiled to first responder(call the keyboard out), than then webView will display normally。(but became 2 part ,both WKCompositingView).
can anyone tell me why?

Final , I solved this question by adding [webViewCell setNeedsLayout] in the scrolldViewdidscroll method.

I think, first cell not show out of content. You can add webview into view. After that, add this view into first cell. First cell will show out of content webview.

Related

UITableView: Can't find a way to move/align the tableIndex element up

I have a UITableView and I am using a tableIndex, my problem is that when the keyboard comes up, it partially hides the tableIndex.
An acceptable solution would be to move the tableIndex up (like what the Contacts App does) when the keyboard appears, and show the most of it, but can figure out a way to do this. Any ideas of code snippet I can try?
The way to do this is to register to Keyboard Will Show notification and then update the height of your controller's view. You could also embed everything in a scroll View so that once the keyboard rises, your view becomes smaller and scrollable.
It is honestly a bit annoying to set up, so, if you are open to using CocoaPods then IQKeyboardManager is probably your best bet which can be found here: https://github.com/hackiftekhar/IQKeyboardManager

Button Responsiveness at UIScrollView

I am dynamically creating a uiscrollview and i place some uiview's that contains some label and buttons inside to display some news. Every button inside the sub uiview calls a rest function to like, unlike or share the news. Some of the buttons opens overlay screens like comment news. I am assigning actions to buttons inside the main form that contains the uiscrollview.
When i click a button that opens an overlay screen. When i close the overlay screen and hit Like button, it does not respond to touches. After attempting one or two more times, it works.
Does anyone has any idea about this issue?
Are you using UITapGestureRecogniser for "Click action"? If yes, you propably want to set flag "cancelsTouchesInView = NO" for this recogniser.
Check to see if there is a clear view covering your button. That view will consume your tap, so the button never sees it.

Unable to change the view size in XIB?

I am trying to make the view controller as size as 300x400, i have done following things,
Open the XIB and go to the Size inspector
Changed the width and height properties to 250 and 300
Saved the file and closed interface builder
But its Not working ??
Just double check with your code whether anywhere frame assign programmatically. If NO, just do following step.
1) Clean and build -> Run. If not work, go to second step.
2) Delete app on simulator and run again.
Right click on XIB
Choose open As
chose source code
and change width and height ..
First of all its important to know that how you are checking size is changed or not.
If you are doing addSubview of this resized xib into other view controller than you feel the change in xib. But in case you are using Push view controller than you will not feel the change. Because view controller will show over the window so you can not change the window size.
Note :
If you want to show the resized view as an subview in any other page than you need to take subview in that view & make add subview of the current view.
Hiii #Gautam, this can be possible, you can do the following things,
Clean your project because sometimes it will not recompiled. Run it again. If this not work then you can use 2nd way
Open the source code of filename.xib by using right clicking that xib and perform change to height and width.
Hope this will work for you...
Thank you...

Content Editable UIWebView scrolls and overlaps over the button/images of uiview in iOS

I have a view with few buttons and UIWebView which loaded content editable HTML.
In UIWebView i am inserting images/Canvas using both native and javascript functionality.
Since the WebView is editable whenever webview is clicked keyboard comes up. Now when we are inserting/editing a image/canvas keyboard should hide. So for that i am checking for tap event, getting the id of the element at that position and hiding the keyboard if that is a image/canvas using [webview endEditing:YES];.
Now the problem what i am facing is that if i add 2-3 images and then clicks on the webview, webview starts moving from its position and overlaps the button/images kept at the uiview. So the button are not visible and i am not able to perform the actions related to that.
Issue resolved. I was using some kind of animation when the keyboard was show/hidden. Once i removed that uiwebview doesn't moves.

Trouble figuring out how to add a custom view above WebView within the same ScrollView

I'm trying to create an app that will have an interface similar to the Mail app on the iPhone. When you view an email message on the built-in Mail app, it displays sender/receiver information in addition to the subject in an area before the message. I was thinking of using a WebView for the message portion, but I can't figure out a way to have some custom view appear above the WebView while still within the same ScrollView.
What is the best way to implement this? To me the best option seems to be generating the "custom view" at the top in HTML/CSS, and simply appending the message's HTML afterward. I've looked at trying to put a WebView with another view inside a ScrollView, but it seems to go against Apple's design guidelines.
Any ideas or suggestions would be great.
Thanks,
Thomas
I don't hink it is against Apple guidelines.
What I'd do in your case is the following.
First create the scroll view
Place inside it your fixed height header (with subject, etc...)
Then place inside the scrollview a webView with an y offset of your headers height.
After the webView is done loading call [webView sizeToFit]; (wich resizes the view trying not to crop subViews)
Maybe you'll have to set the y offset again (frame.origin.y=offset)
And then set the scrollview content size to the sum of the two heights:
scrollView.contentSize=CGSizeMake(width, headerView.frame.size.height + webview.frame.size.height);
I'm not really confident with what [webView sizeToFit] is going to do. I've read you can also use [webView sizeThatFits:CGSizeZero]; . It will apparently return the needed size for the webView.
The you would simply have to change the webviews frame size to the return value of that function and use the same contentsize statement as before.
Hope this helped
PS: I think it's a bad idea to use html as a replacement for views. It's much slower and it takes initial time to load. The only use I've found to it is for displaying formatted text.

Resources