Update IBOutlet of UIScrollView with new content - objective-c

I have made a paging using UIScollView. Pages are created 2 and when user scroll it's changes.
Created page is loaded with new content.
Same page have other UIScrollView with UItextView of subviews.
But when i scroll to other page, my UItextViews added to page UIScrollView don't upadtes.
It's updates just then when i scroll that UIScrollview.
Tried this:
for (UIView *childView in _scroller.subviews)
{
[childView setNeedsDisplay];
}
But this not helping
Maybe some one have other suggestions ?
Thanks.

Related

UIScrollView scrolls to different position while animating presentation of modal view controller

I'm using a UIScrollView for paging three different UIViewControllers. The pager initializes to display page 1 from start. So the user can swipe left or right from the beginning. When I present a modal view controller from the mid view controller, the UIScrollView temporarily scrolls to the first page during the animation of the presented view controller. When I dismiss the modal view controller everything's back to normal and the UIScrollView displays the center view controller.
I would expect (and want) the UIScrollView to keep it's position during the animation.
This is not a technical bug that causes a crash or something, it's just ugly.
Anyone ever had that before? Any idea how to fix it?
I've had this same problem, and after much investigation it appears to be a bug in UIKit relating to scrollviews and AutoLayout. Here's the 'fix'...
In viewDidDisappear:, save the current scrollview contentOffset to a property, and reset it to zero:
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
self.previousContentOffset = self.scrollView.contentOffset;
self.scrollView.contentOffset = CGPointZero;
}
Then, in viewWillAppear:, reset the content offset back to what it was previously. I had to dispatch this onto the main queue to get it to work correctly:
- (void)viewWillAppear:(BOOL)animated
{
if (!CGPointEqualToPoint(self.previousContentOffset, CGPointZero))
{
dispatch_async(dispatch_get_main_queue(), ^{
self.scrollView.contentOffset = self.previousContentOffset;
});
}
}

UINavigationBar to a higher xib layer index

Similar to how z-index works in HTML, I want to make my UINavigationBar be on the highest layer so that everything in my scroll view goes underneath it.
I currently just have a xib with a UINavigationBar located at the top with a UIScrollView below it vertically that has Bounce Vertically checked. When you slide the scroll view the content from the scroll view will appear to be above the UINavigationBar and covers it.
You can set the zPosition of navigationBar to the topmost layer as below
navigationController.navigationBar.layer.zPosition =[[self.view subviews] count];
If you use a UIViewController I would suggest using this code :
self.navigationController.navigationBarHidden = false;
But if you are using a plain UIView I will refer you to the UIView documentation http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/c_ref/UIView
Look for the #property(nonatomic, readonly, copy) NSArray *subviews and other subviews related method.
You can order your view relative to each other with those method.

How to send a message back to UIScrollView from a NavigationController stack?

My view controllers are structured like this:
> UIWindow
> - RootViewController with UIScrollView (2 pages, pagingEnabled)
> -- UINavigationController (in the first page of the scrolling view)
> --- HomePageViewController (plus other ViewControllers pushed on the stack)
> -- MinutiaViewController (second page)
UIScrollView holds the UInavigationController as a subview
[scrollView addSubview:navController.view];
In my scenario I want to:
disable UIScrollView scrolling (scrollEnable=NO) once a new view is pushed onto the UINavigationViewController
enable UIScrollView again (scrollEnable=YES) once the new view is popped and the UINavigationController shows its root again
(HomePageViewController)
I figured out how to disable the scrollView scrolling when pushing a new view.
But cannot figure out how to enable the scrollView scrolling when the new view pops off the stack.
So far I tried
1 triggering viewWillAppear; viewWillDisappear; manually and sending a
message to UIScrollView from HomePageViewController's viewWillAppear
e.g.
[self.navigationController.parentViewController performSelector:#selector(enableScrollAgain)];
2 designated the RootViewController as a UINavigationController delegate to handle its
events
None seems to work so far. All advice appreciated!
Have you tried using Notifications ? You could add the RootView to observe a notification form the navigation controller, when you get that notification you can disable scrolling. Look into NotificationCenter.
Hope this helps

UIScrollView not scrolling in xcode 4?

For some reason UIScrollView is not working. It did work before I add the content but after it stop working. I'm stuck can someone help me out!
Here is my code
This is the code for my UIScrollView
#interface EditAccountViewController : UIViewController {
IBOutlet UIScrollView *svScroller;
}
Here is my view Load code
- (void)viewDidLoad
{
[super viewDidLoad];
[svScroller setScrollEnabled:YES];
[svScroller setContentSize:CGSizeMake(320, 930)];
}
Here is my objects view
View
Scroll View
Image View
View
View
Toolbar
It works also with that.
To my understanding "autolayout" set constraint after loading the view so the problem could be that you set your constrains on viewDidLoad and just after that "autolayout" changes that. Try to set this constrains on viewDidAppear.
Get it from: scrollview xcode4.5 autolayout. Thanks.
Always keep in mind that the content view needs to be larger than the UIScrollView instance frame size. If it isn't, it will not enable scrolling.
This applies to UITableView as well. The scrolling for UITableView will not appear unless there are more rows to be displayed than actually are.
I resolved the issue. I just bump the height in [svScroller setContentSize:CGSizeMake(320, 1500)]; and It's working fine.

UI scroll View Help

Hi i need help with UIScrollView..
i m loading tens views onto my scroll view.. am loading them correctly.. I m Using IBoutlet for showing scroll view.
now the problem is i want my scroll view to reset to nil on disappearing and reappearing of mine view..
I m making its delegate to nil. and releasing mine array in which the images are stored.. To make a scroll view nil that is to delete all the subviews of a scroll view do i have to reinitialize the scroll view..
Sorry for my english.. and please any help or hint will be appreciated.
just remove your scrollview subViews and add subview when you want dont need to reinitialize
NSArray *scrollViewSubViews=[yourScrollView subviews];
for(UIView *view in scrollViewSubViews)
{
[view removeFromSuperview];
}
If you wanna Add a view just
[yourScrollView addSubview:yourimageViews];