stop tableviewcontroller scrolling - objective-c

I am adding a textview to UITableviewController's view and now I want to stop the scrolling of view of UITableviewController.
But I am unable to do so. As its a view so no enable and disable scrolling properties like table view are existing.
Any ideas???

self.tableView.scrollEnabled = NO;
where self is your UITableViewController

Related

Change self.view's class type

I have a app out for testing right now that's almost completely done - just a few bug fixes left. Unfortunately, the customer decided that they'd like the entire main page of the app to be inside of a scroll view (so that there's more room for the table at the bottom). I already have everything set up and I don't really want to move everything and change references. Is there an easy way to change the class of the main view to a scroll view? I've already tried changing the class in IB and setting the class type in the init method. If there isn't I'll probably just throw the top section of the view into a nib file and load it as a custom cell.
-EDIT- I ended up changing the class type in IB and then doing
[(UIScrollView *) self.view setScrollEnabled:YES];
[(UIScrollView *) self.view setContentSize:CGSizeMake(0,2000)];
in viewDidLoad. Thanks for the help, wish I could accept all your answers.
When you are referring to [self view], I am going to assume you mean in a view controller. The view of a view controller can be any view that derives from UIView. Thus a scrollview is completely acceptable.
I don't really want to move everything and change references.
what would you have to move? why would you have to change references? Only thing you should need to do is add a scroll view to your view controller, set the view controllers view to it, and add the current view as a subview to the new scroll view. No references need to be changed, nothing has to be moved.
Refer to loadView method in documentation of view controller.
Here is a simple (untested!) example
- (void)loadView {
UIScrollView *scrollView = [[UIScrollView alloc] init] autorelease];
//Set the properties of scrollview appropriately....
self.view = scrollView;
}
Now the root view of your view controller will be a scroll view.
Note
- As the documentation states, do not do this if you are using interface builder to initialize your views/view controller. I could not tell from your description if this was the case or not. If it is, you should be able to change the view type in interface builder.
You need to set the contentSize property of your scrollview.
Since you are using IB, the easiest way to do this is to put all your UI elements into a view and add this single view to your scroll view. In the viewDidLoad method, set the content size of the scrollview to be the same size as the view that contains all your UI.
As an aside, there are much easier ways to reference views than walking down the view hierarchy, as you seem to be doing. viewcontroller.view.something.tableview. Add a connection to the tableview from your view controller in IB and it doesn't matter where that tableview is in the view hierarchy. You'll always be able to reach it from viewcontroller.tableview, no matter how you rearrange your nibs.
I think you have to use a pointer with proper type. Example for Google Maps: let's say you changed you base view's class to GMSMapView.
MapViewController.h
#property GMSMapView *mapView;
MapViewController.m
-(void)awakeFromNib{
[super awakeFromNib];
self.mapView = (GMSMapView*)self.view;
// ... etc.
}

How to show a UIView OVER a UIPopoverController

In my app, I have my main view and when i click a button, a UIPopoverController is shown over my main view (not fullscreen so i still see the view behind) containing a UITableView. When I click one of the tableview cells, I want to show a custom view centered on screen (simple view informing the user that the app is processing) that will fade in and fade out during a specific amount of time.
The problem is that my custom view always appears UNDER the UIPopover...I tried all I can think of, bringSubviewToFront etc...Nothing works... I also tried to wrap my custom view in a UIViewController and use [mainView presentViewController:myCustomView ...] but when I do that the main view disappear
Someone can help?
Thx
Thx Ole Begemann, this question was indeed a duplicate.
Although, the solution to my problem is not to subclass UIWindow but to add my UIView to the key UIWindow :
NSArray * windows = [[UIApplication sharedApplication] windows];
UIWindow* win0 = [windows objectAtIndex:0];
[win0 addSubview:loadingView];
[win0 bringSubviewToFront:loadingWindow];

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];