UIScrollView changes content offset on presentModalViewController - iphone

A UIScrollView in my view hierarchy is acting funky whenever I present a modal view controller above it. It automatically adjusts the content offset and moves my content down about 40 pixels. I can't seem to figure out how to stop this.
After snooping around I've found that the presentModalViewController somehow triggers the private method _adjustContentOffsetIfNecessary on my UIScrollView and this is what is changing the offset.
Any idea if this is a bug on Apple's part? Or is something getting set screwy in my UIScrollView? Anyway to disable this _adjustContentOffsetIfNecessary method or at least this side effect?

Although it is not fancy, I solved this resetting the content offset in the viewDidAppear of the presentingViewController.

Try setting the property automaticallyAdjustsScrollViewInsets of your ViewController, that contains the UIScrollView, to "NO"

Related

Cannot Impliment UITextview inside a UIPageViewController

I have a strange issue , I have a page app in which one page I had used a UITextView, but when I tap on the UITextView it moves to the next page, can't write anything on it.
There is no issue when I use UIPageViewControllerTransitionStylePageCurl. The only issue is with UIPageViewControllerTransitionStyleScroll. Anyone know the solution? please help me
I ran into the same issue myself, and it appears that it's a consequence of some default behavior that occurs whenever a UITextField or UITextView becomes first responder inside a UIScrollView.
The solution to prevent your UITextView from scrolling the UIPageViewController is to first embed it into a UIScrollView instead of directly into a page's main view.
This works because when the UITextView becomes first responder it will search for the earliest superview in the view hierarchy that is of type UIScrollView, and it will scroll that scrollview to accommodate for the keyboard covering the screen. If you don't wrap the UITextView inside a UIScrollView, your UIPageViewController's internal UIScrollView will be chosen and scrolled, producing undesired behavior.
You can refer the link below..
UIPageViewControllerTransitionStylePageCurl - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html
UIPageViewControllerTransitionStyleScroll - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html

UISegmentedControl Not Redrawn

I'm using a UISegmentedControl to show headers for a table view. When the orientation changes, the headers are resized depending on the labels in the table view underneath. Despite being connected up in IB, I have to move the phone around a bit to fire a orientationChanged notification and update the widths. I've even tried setting the first segment width to 0 in IB, then again in viewDidLoad, but all headers are the same width when the view loads. I've tried using performSelector:afterDelay to make sure the view is actually on screen, and also calling setNeedsLayout and setNeedsDisplay, but nothing seems to work. I simply have to jiggle the phone around.
Is this a bug anyone has experience with or am I making a daft mistake?
I'm setting the width as below:
[segSortOrder setWidth:0.0 forSegmentAtIndex:0];
The only solution I came up with for this was to use performSelector:afterDelay and using self.view.bounds.size.width with a variable amount of padding (how much is trial and error for each ViewController. Not ideal but it does the job.

Canceling the scrolling animation when keyboard pops up on iphone

I have a UIViewController that contains UITextField. I set the inputAccessory of the textfield to a UIToolbar that I create.
My ViewController's view is inside a UIScrollView (To handle the events of keyboard popping up)
Before:
Now, when the keyboard pops up, suddenly my ScrollView is setting it's contentOffset.y to 64 with animation, so part of my view is pushed above the top of the screen:
After:
This is done by the framework because I'm using a toolbar for inputAccessoryView.
If i'm dropping the toolbar there is no animation and no content offset.
Is anyone knows how can I disable this automatic animation and scrolling?
Thank you!
You can use a combination of boolean flags and your UIScrollViewDelegate to prevent the scrolling from taking place. Scroll view delegates can be used to detect when scrolling is taking place, modify the type of scrolling, and also simply prevent it from happening, so your best approach is probably to look into detecting when the keyboard goes up (via a notification or text field delegate, whichever is more appropriate) and using that in combination with your scroll view delegate.

scrollViewDidScroll not executing

I think have decent experience working with iPhone development.
as much I know.. I did set up the delegate..
I have from top to botton
UIView --> UIScrollView--> UITextView
I tried everything... to get the event scrollView to fire the scrollViewDidScroll event.
is anything wrong with the structure..
there not much of the code to post here.
what I am trying to do is.. do something when UITextView is scrolled.
Sorry did not respond... Just wanted to share in case anyone need this...
I used delegate methods of parent i.e. UIView for UIScrollView i.e. Child it worked..
It's hard to say without some code or a screenshot. Is the scroll view actually scrolling? If you set it up in Interface Builder, did you change the size of the scroll view's contentSize in code so that it can actually scroll? Maybe the text view is eating the scroll events; did you try setting the text view's delegate to see if it's firing a scrollViewDidScroll event?

determine if uiview is displayed

is there a possibility to determine if an uiview obj is going to be displayed. imagine: you have 2 uiviews in an uiscrollview. now you are going to switch per gesture from the first view to the second. the first view now is NOT in the viewport. now you are going to go back to the first view. and now I want to be notified that this view is in viewport, or is redisplayed. the same has to be for the second view. I have not found any callback or something like this.
You make sure your UiViewController overrides viewWillAppear: (before it appears this method is called) or viewDidAppear: (after this method is called).
See: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewWillAppear:
That depends what you mean by "switch". If one view is just scrolled out of the visible area of the scrollview, but still remains attached as a subview to it, then you may want to check if the bounds of your view overlap those of the scrollviews visible area.
You could do this by using UIScrollView Delegate's scrollViewDidScroll: method to implement a check for overlaps while the user is scrolling.
If however your view is actually removed from the viewstack, then you may want to subclass UIView and implement willMoveToSuperview: to check if the view has been added to the scrollview again.