Orientation is not working in ios6? - iphone

I am having problem in Orientation for ios6. same code is working fine for ios5 or 5.1.
I have used - (BOOL) shouldAutorotate and -(NSInteger)supportedInterfaceOrientations as per the ios6 standard. But still "willRotateToInterfaceOrientation" and "didRotateToInterfaceOrientation" is not getting called.
Here is my code:--
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (!UIInterfaceOrientationIsPortrait(lastOrientation) || !UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
if (!UIInterfaceOrientationIsLandscape(lastOrientation) || !UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
{
CGRect frame;
int viewAlpha;
lastOrientation = toInterfaceOrientation;
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
viewAlpha = 1;
[MovieControlContainerLandscape setHidden:YES];
if (isDauntless) {
[self.navigationController setNavigationBarHidden:NO animated:YES];
} else {
[self.navigationController setNavigationBarHidden:NO];
}
frame = iPad ? CGRectMake(0, 88, 768, 432) : CGRectMake(0, 88, 320, 180);
[movieContainer removeGestureRecognizer:toggleMediaControl];
}
else
{
[PromptToBuy dismissWithClickedButtonIndex:0 animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
viewAlpha = 0;
[MovieControlContainerLandscape.layer setCornerRadius:22];
[MovieControlContainerLandscape.subviews.lastObject addSubview:[MediaControls use]];
if (isDauntless) {
[self.navigationController setNavigationBarHidden:YES animated:YES];
} else {
[self.navigationController setNavigationBarHidden:YES];
}
frame = iPad ? CGRectMake(0, 0, 1024, 768) : CGRectMake(0, 0, 480, 320);
[movieContainer addGestureRecognizer:toggleMediaControl];
if (isDauntless) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
}
if(TSFullScreen)
{
[movieContainer setAlpha:1];
}
if (isDauntless) {
[UIView commitAnimations];
}
}
[viewContainer setAlpha:viewAlpha];
// Size the overlay view for the current orientation.
[movieContainer setFrame:frame];
}
}
/* Sent to the view controller after the user interface rotates. */
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (!UIInterfaceOrientationIsPortrait(lastOrientation) || !UIInterfaceOrientationIsPortrait(fromInterfaceOrientation))
if (!UIInterfaceOrientationIsLandscape(lastOrientation) || !UIInterfaceOrientationIsLandscape(fromInterfaceOrientation))
{
float duration = .5;
if (fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
if (isDauntless) {
[UIView transitionWithView:movieContainer duration:duration options:UIViewAnimationOptionTransitionNone animations:^{
/* Move movie view to parent center. */
[self.moviePlayerController.view setCenter:movieContainer.center];
} completion:^(BOOL finished) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
CGRect frame = movieContainer.frame;
/* Size movie view to fit parent view. */
frame.origin.y = 0;
[self.moviePlayerController.view setFrame:frame];
[UIView commitAnimations];
CGPoint center = CGPointMake(movieContainer.center.x, -50);
[MovieControlContainerLandscape setTag:0];
[MovieControlContainerLandscape setHidden:NO];
[MovieControlContainerLandscape setCenter:center];
[self toggleMovieController];
}];
} else {
CGRect frame = movieContainer.frame;
/* Size movie view to fit parent view. */
frame.origin.y = 0;
[self.moviePlayerController.view setFrame:frame];
CGPoint center = CGPointMake(movieContainer.center.x, -50);
[MovieControlContainerLandscape setTag:0];
[MovieControlContainerLandscape setHidden:NO];
[MovieControlContainerLandscape setCenter:center];
[self toggleMovieController];
}
}
else
{
if (!isDauntless) {
[MovieControlContainer setFrame:CGRectMake(0, 44, 768, 68)];
}
[MovieControlContainer addSubview:[MediaControls use]];
//NSLog(#"MovieControlContainer is %#, MovieControlContainer subviews: %#",MovieControlContainer,[MovieControlContainer subviews]);
if (isDauntless) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
}
if(TSFullScreen){
[movieContainer setAlpha:0];
}
CGRect frame = movieContainer.frame;
/* Size movie view to fit parent view. */
frame.origin.y = 0;
[self.moviePlayerController.view setFrame:frame];
if (isDauntless) {
[UIView commitAnimations];
}
}
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return !mediaTypeIsAudio && isOrientationSupported;
}
//----supported method for ios6--------//
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSInteger)supportedInterfaceOrientations{
NSInteger mask = 0;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight])
mask |= UIInterfaceOrientationMaskLandscapeRight;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft])
mask |= UIInterfaceOrientationMaskLandscapeLeft;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait])
mask |= UIInterfaceOrientationMaskPortrait;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown])
mask |= UIInterfaceOrientationMaskPortraitUpsideDown;
return mask;
}
//i have set the rootviewcontroller in appdelegate file
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController.
Please help me to take out from this problem. I am not able to find the solution for this.Thanks in Advance !!.

In ios6 you have to use this method for vieworientation
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationMaskAll;
}
And check my answer Link

Related

iOS Hiding tab bar in iOS 6 creates black bar (fix for iOS 6 breaks iOS 7!)

I've got a tabbed application and in one tab there is a UIWebView. When I rotate the device to landscape I've made the UIWebView full screen while hiding the status and tab bar.
I've got it working in iOS 6 - originally when rotating and hiding the tab bar it would leave a black space where the tab bar was, so the fHeight code fixes this. However, on iOS 6 it worked perfectly, but now it actually creates the black bar problem iOS 6 was having!! Any ideas for a workaround to this?
Please see my edit below this
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
{
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[self hideTabBar:self.tabBarController];
[[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationSlide];
}
else
{
[self showTabBar:self.tabBarController];
[[UIApplication sharedApplication] setStatusBarHidden:FALSE withAnimation:UIStatusBarAnimationSlide];
}
}
- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
float fHeight = screenRect.size.height;
if( UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
{
fHeight = screenRect.size.width;
}
for(UIView *view in self.tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
view.backgroundColor = [UIColor blackColor];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
float fHeight = screenRect.size.height - 49.0;
if( UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
{
fHeight = screenRect.size.width - 49.0;
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
}
}
[UIView commitAnimations];
}
//Edit
I've tried using this but I'm not sure how to pass in the view properly - I've tried self.view and webView and others but I can't get it to work on both iOS 6 and 7! Any kind of idea at all would be really helpful! Let me know if you need more info
- (void)setTabBarHidden:(BOOL)hidden view:(UIView *)view animated:(BOOL)animated
{
if (self.tabBar.hidden == hidden)
return;
CGRect screenRect = [[UIScreen mainScreen] bounds];
float height = 0.0f;
if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
{
height = screenRect.size.width;
}
else
{
height = screenRect.size.height;
}
if (!hidden)
{
height -= CGRectGetHeight(self.tabBar.frame);
}
void (^workerBlock)() = ^() {
self.tabBar.frame = CGRectMake(CGRectGetMinX(self.tabBar.frame), height, CGRectGetWidth(self.tabBar.frame), CGRectGetHeight(self.tabBar.frame));
view.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame), CGRectGetWidth(view.frame), height);
};
void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
self.tabBar.hidden = hidden;
};
if (animated)
{
[UIView animateWithDuration:0.25f animations:workerBlock completion:completionBlock];
}
else
{
workerBlock();
completionBlock(YES);
}
}
I've created a a public Gist on Github for how we're doing this.
This solution has gone through several iterations due to #Chris Byatt and our team trying it out. So, make sure you download the latest revision from there.
The method signature has been simplified to
- (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated;
You can call it like this within your UIViewController subclass:
[self.tabBarController setTabBarHidden:YES animated:YES];
OK guys, after struggling with this for about two hours, my colleague taught me the right way to do it. There is actually a very simple fix that I can't find online:
just put :
self.hidesBottomBarWhenPushed = YES;
In the init method of your viewController and comment out the self.tabBar.hidden related code.
I eventually got this working, but it took a while. It stemmed from a mixture of my original code and some of JRG-Developers work.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
BOOL toLandscape = UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
CGRect screenRect = [[UIScreen mainScreen] bounds];
void (^workerBlock)() = ^() {
[[UIApplication sharedApplication] setStatusBarHidden:toLandscape withAnimation:UIStatusBarAnimationSlide];
float height = toLandscape ? screenRect.size.width : screenRect.size.height - CGRectGetHeight(self.tabBarController.tabBar.frame);
float width = toLandscape ? screenRect.size.height : screenRect.size.width;
webView.frame = CGRectMake(CGRectGetMinX(webView.frame),
CGRectGetMinY(webView.frame),
width,
height);
[self moveTabBarToPosition:height];
};
[UIView animateWithDuration:0.25f animations:workerBlock];
}
//Moving the tab bar and its subviews offscreen so that top is at position y
-(void)moveTabBarToPosition:(int)y {
self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, y, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
for(UIView *view in self.tabBarController.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)];
view.backgroundColor = [UIColor blackColor];
}
}
}
In my case this is for my webview but theoretically you can give it any view. Works in iOS 6 and 7
-(void) hideBottomTabs{
// Get the size of the main screen
CGRect fullScreenRect = [[UIScreen mainScreen]bounds];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){
UITabBar *bar = ((UITabBarController *)self.parentViewController).tabBarController.tabBar;
fullScreenRect.size.height += ViewHeight(bar);
}
// Hide the tab bar
((UITabBarController *)self.parentViewController).tabBarController.tabBar.hidden = YES;
// Resize and fill the screen
[[((UITabBarController *)self.parentViewController).view.subviews objectAtIndex:0] setFrame:fullScreenRect];
}
I have solved my problem in a such way.

How do I pass touch events through to parentViewController?

I have a UIViewContoller with a few container(child) UIiewsController. The main UIViewController (mvc) contains:
1.) A UICollectionView that occupies the entire view of mvc (it is above mvc.view but below all other controls).
2.) A UIViewController that displays search options (s1vc)
3.) another similar to #2 (s2vc)
4.) another similar to #2 (s3vc)
I have added gesture recognizers to mvc so that a user can hide/show each of the child view controllers by swiping them off of the screen.
The problem is that when a user swipes any of the svcs off of the screen, they cannot scroll the mvc's collectionView.
Here is how I am hiding/showing the svcs:
-(void)swipeLeftGestureHandler:(UIGestureRecognizer*)gestureRecognizer{
SMLOG(#"Swiped Left");
if([SMUser activeUser] == nil) return;
if([self gestureHorizontalScreenSide:gestureRecognizer] == kHorizontalScreenSideLeft){
[self hideFacets];
}
else{
[self showAccordion];
}
}
-(void)swipeRightGestureHandler:(UIGestureRecognizer*)gestureRecognizer{
SMLOG(#"Swiped Right");
if([SMUser activeUser] == nil) return;
if([self gestureHorizontalScreenSide:gestureRecognizer] == kHorizontalScreenSideLeft){
[self showFacets];
}
else{
[self hideAccordion];
}
}
-(void)hideFacets{
if(self.facetVisible == NO) return;
[UIView animateWithDuration:0.25
animations:^{
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x - newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
self.facetVisible = NO;
}
completion:^(BOOL finished){
self.facetViewController.view.hidden = YES;
self.facetViewController.view.userInteractionEnabled = NO;
}];
}
-(void)showFacets{
if([SMUser activeUser] == nil) return;
if(self.facetVisible == YES) return;
self.facetViewController.view.userInteractionEnabled = YES;
[UIView animateWithDuration:0.25
animations:^{
self.facetViewController.view.hidden = NO;
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x + newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
self.facetVisible = YES;
}
completion:^(BOOL finished){
}];
}
As you can see I'm toggling the svc.view.hidden property and then I also tried toggling th svc.userInteractionEnabled.property but no luck. Still cannot swipe the collection view by swiping where the facets view controller was/is.
Any ideas?
The solution here is to add another outlet (using IB) for the container view in the parentViewController (I called it facetContainerView in this code) and then set it's userInteractionEnabled property.
-(void)hideFacets{
if(self.facetVisible == NO) return;
self.facetVisible = NO;
[UIView animateWithDuration:0.25
animations:^{
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x - newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
}
completion:^(BOOL finished){
self.facetViewController.view.hidden = YES;
self.facetContainerView.userInteractionEnabled = NO;
}];
}
-(void)showFacets{
if(self.facetVisible == YES) return;
self.facetVisible = YES;
self.facetContainerView.userInteractionEnabled = YES;
[UIView animateWithDuration:0.25
animations:^{
self.facetViewController.view.hidden = NO;
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x + newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
}
completion:^(BOOL finished){
}];
}
I was curious as to how this new view outlet was different from self.facetViewController.view, so I inserted this code to compare addresses (they are different indeed). I'm not sure about the heirarchy, but it seems that there is an extra view layer that I was not aware of.
NSLog(#"self.facetViewController.view: %p", self.facetViewController.view);
NSLog(#"self.facetContainerView: %p", self.facetContainerView);
Hopefully this will help someone at some point.

addSubview animation works only after second time

I am trying to make my label appear with animation:
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
if (isShowingRectangleLabel == NO) {
[UIView transitionWithView:rectangleLabel duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^ { [self.view addSubview:rectangleLabel]; }
completion:nil];
NSLog(#"action");
isShowingRectangleLabel = YES;
} else {
[UIView transitionWithView:rectangleLabel duration:0.5
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^ { [rectangleLabel removeFromSuperview]; }
completion:nil];
isShowingRectangleLabel = NO;
}
}
But this animation works only after second adding to subview. How can I fix it?
EDIT To clarify, addSubview works but without animation.
Do this:
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
if (isShowingRectangleLabel == NO) {
[UIView transitionWithView:self.view duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^ { [self.view addSubview:rectangleLabel]; }
completion:nil];
NSLog(#"action");
isShowingRectangleLabel = YES;
} else {
[UIView transitionWithView:self.view duration:0.5
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^ { [rectangleLabel removeFromSuperview]; }
completion:nil];
isShowingRectangleLabel = NO;
}
}

Tableview pulldown to refresh

Ha ii everybody,i am familiar with pullDownToRefresh in tableview but in want pulluptorefresh in my application like the pocket-sword bible application chapter loading pull-up for next-chapter and pulldown for previous chapter,i done the ordinary pulldown method,but i want pull-up,i tried to customize the existing pulldown code but no luck,i tried more than 4 days for this. i want to implement pull-up below the footer just like the pulldown just-above the header.
anyone have any idea about this please help me.
Kind regards Nipin.
- (void)addPullToRefreshHeader {
refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
refreshHeaderView.backgroundColor = [UIColor clearColor];
refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, REFRESH_HEADER_HEIGHT)];
refreshLabel.backgroundColor = [UIColor lightGrayColor];
refreshLabel.font = [UIFont boldSystemFontOfSize:16.0];
refreshLabel.textColor = [UIColor whiteColor];
refreshLabel.textAlignment = UITextAlignmentCenter;
refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"arrow.png"]];
refreshArrow.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 27) / 2,
(REFRESH_HEADER_HEIGHT - 44) / 2,
27, 44);
refreshSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
refreshSpinner.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 20) / 2, (REFRESH_HEADER_HEIGHT - 20) / 2, 20, 20);
refreshSpinner.hidesWhenStopped = YES;
[refreshHeaderView addSubview:refreshLabel];
[refreshHeaderView addSubview:refreshArrow];
[refreshHeaderView addSubview:refreshSpinner];
[self.table addSubview:refreshHeaderView];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (isLoading) return;
isDragging = YES;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (isLoading) {
// Update the content inset, good for section headers
if (scrollView.contentOffset.y > 0)
self.table.contentInset = UIEdgeInsetsZero;
else if (scrollView.contentOffset.y >= -REFRESH_HEADER_HEIGHT)
self.table.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (isDragging && scrollView.contentOffset.y < 0) {
// Update the arrow direction and label
[UIView beginAnimations:nil context:NULL];
if (scrollView.contentOffset.y < -REFRESH_HEADER_HEIGHT) {
// User is scrolling above the header
refreshLabel.text = #"Release to previous chapter...";
[refreshArrow layer].transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
} else { // User is scrolling somewhere within the header
refreshLabel.text = #"Pull down to previous chapter..";
[refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
}
[UIView commitAnimations];
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (isLoading) return;
isDragging = NO;
if (scrollView.contentOffset.y <= -REFRESH_HEADER_HEIGHT) {
// Released above the header
[self startLoading];
}
}
- (void)startLoading {
isLoading = YES;
delegate.selectedChapter = [NSString stringWithFormat:#"%d",[delegate.selectedChapter intValue] + 1];
[delegate reloadVerses];
[self resetReadViewToVerse:1];
// Show the header
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
self.table.contentInset = UIEdgeInsetsMake(REFRESH_HEADER_HEIGHT, 0, 0, 0);
refreshLabel.text = #"Loading...";
refreshArrow.hidden = YES;
[refreshSpinner startAnimating];
[UIView commitAnimations];
// Refresh action!
[self refresh];
}
- (void)stopLoading {
isLoading = NO;
// Hide the header
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDidStopSelector:#selector(stopLoadingComplete:finished:context:)];
self.table.contentInset = UIEdgeInsetsZero;
[refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
[UIView commitAnimations];
}
- (void)stopLoadingComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
// Reset the header
refreshLabel.text =#"Pull down to previous chapter..";
refreshArrow.hidden = NO;
[refreshSpinner stopAnimating];
}
- (void)refresh {
// This is just a demo. Override this method with your custom reload action.
// Don't forget to call stopLoading at the end.
[self performSelector:#selector(stopLoading) withObject:nil afterDelay:2.0];
}
I dont know exactly about your task. But try out following code which identifies the scrollPosition of UITableView :
NSIndexPath* ipath = [NSIndexPath indexPathForRow: cells_count-1 inSection: sections_count-1];
[tableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES]
For more reference go to Link

How to hide UITabBarController programmatically?

Is it possible to hide it with animation ?
A UITabBar inherits from UIView, so you can hide it and animate it like you would with a standard UIView.
- (void) hideTheTabBarWithAnimation:(BOOL) withAnimation {
if (NO == withAnimation) {
[theTabBar setHidden:YES];
} else {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:nil];
[UIView setAnimationDuration:0.75];
[theTabBar setAlpha:0.0];
[UIView commitAnimations];
}
}
You should use this code:
self.tabBarController.tabBar.hidden=YES;
You can also hide it using the attributes inspector:
but not with an animation.
-(void)hideTabBar
{ UITabBarController * tabbarcontroller= appDelegate.tabBarVC;
if (tabbarcontroller.tabBar.isHidden)
{
return;
}
tabbarcontroller.tabBar.hidden=YES;
CGRect frm=tabbarcontroller.view.frame;
frm.size.height += tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
}
-(void)showTabBar
{ UITabBarController * tabbarcontroller=appDelegate.tabBarVC;
if (!tabbarcontroller.tabBar.isHidden)
{
return;
}
CGRect frm=tabbarcontroller.view.frame;
frm.size.height -= tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
tabbarcontroller.tabBar.hidden=NO;
}
here appDelegate is = (AppDelegate *) [[UIApplication sharedApplication] delegate]
tabBarVc is UITabBarController *tabBarVC defined as property in app delegate
hope this helps
Another Solution I use:
Call Methods When You Want to Hide Menu:
//Show Tab Bar
[self showTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: NO animated:YES];
//Hide Tab Bar
[self hideTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: YES animated:YES];
Methods:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}