iOS7 status bar issue that I can't figure out - ios

I have those 2 issues in iOS7 that I can't figure out.
The first issue is that the TableView rows goes beneath the Status Bar, how can I disable it, or to make the section header of the table view to be under the status bar all the time?
The second issue that I have is on the navigation controller the status bar seems to be black with black background and I don't know how to fix it, the view controllers background is white, but the status bar reminds black and I don't know why.
UPDATE:
Still no answer.

I've got the answer in another post, please check it everyone who has problems with iOS6-7 and StatusBar:
UIStatusBar as in Facebook new iOS7 application
Enjoy!

I think you need to do following code.
You will have to check condition for ios7.
You will need these two delegate methods for tableview.
Check my code below.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
int versionValue=[currSysVer intValue];
if(versionValue>=7)
{
return 60;
}
return 0;
}
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 60)];
[headerView setBackgroundColor:[UIColor clearColor]];
return headerView;
}
Hope this helps you.

use these lines of code
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
and
- (BOOL)prefersStatusBarHidden
{
return YES;
}

Answer for your second issue!
Put in your didFinishLaunchingWithOptions:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[self customizeios7];
} else {
[self customizeios6];
}
And make these 2 voids:
-(void)customizeios6 {
UIImage *navBackgroundImage = [UIImage imageNamed:#"navigationbar-ios6"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
}
-(void)customizeios7 {
// SET STATUSBAR TEXT WHITE
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
// SET NAVIGATION IMAGE
UIImage *navBackgroundImage = [UIImage imageNamed:#"navigationbar-ios7"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
}
The image dimensions for your UINavigationBar:
For iOS 6:
640px / 88px
For iOS 7:
640px / 128px

Related

Changing the UINavigationBar background depending on landscape/portrait?

I want my UINavigationBar to rotate properly within my SignatureViewController. This is currently how it looks in Portrait vs Landscapemode when rotating: http://tinypic.com/view.php?pic=2w5573a&s=5#.Uk5kgYapWrg
As you can see the UINavigationBar does not scale on the width when in landscape. My project is built as following:
rootViewController(UINavgationController) ------Modal push-----> SignatureViewController
(portrait only) (portrait/landscape)
Note that I am not using a normal push to the SignatureViewController, I am using a modal one. Just in case I wanna mention this because I am not sure if it can affect the outcome in any strange way?... I have tried different approaches to change the background of the NavigationBar depending on if it is in landscape or portrait. I will post some here below:
try nr1: Not working
- (void) viewWillAppear:(BOOL)animated {
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"bar_nav_black.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"navbar25g.png"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
}
try nr2: Not working
- (void) viewWillAppear:(BOOL)animated {
UIImage *navBarLandscape = [[UIImage imageNamed:#"navbar25g.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(x,x,x,x)];
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"bar_nav_black.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance]setBackgroundImage:navBarLandscape forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
}
try nr3: Not working
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
UIView *v = [[UIView alloc]init];
int a = [[notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey] intValue];
int w = [[UIScreen mainScreen] bounds].size.width;
int h = [[UIScreen mainScreen] bounds].size.height;
switch(a){
case 4:
v.frame = CGRectMake(0,20,w,h);
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"bar_nav_black.png"] forBarMetrics:UIBarMetricsDefault];//Have also tried with UIBarMetricsLandscapePhone...
NSLog(#"willrotate:1");
break;
case 3:
v.frame = CGRectMake(-20,0,w-20,h+20);
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"navbar25g.png"] forBarMetrics:UIBarMetricsDefault];//Have also tried with UIBarMetricsLandscapePhone...
NSLog(#"willrotate:2");
[self.view addSubview:v];
break;
case 2:
v.frame = CGRectMake(0,-20,w,h);
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"bar_nav_black.png"] forBarMetrics:UIBarMetricsDefault];//Have also tried with UIBarMetricsLandscapePhone...
NSLog(#"willrotate:3");
break;
case 1:
v.frame = CGRectMake(20,0,w-20,h+20);
NSLog(#"willrotate:4");
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:#"navbar25g.png"] forBarMetrics:UIBarMetricsDefault];//Have also tried with UIBarMetricsLandscapePhone...
}
Note that in try nr3 the NSLog works but it refuses to change the background of the UINavigationBar. So, any ideas what I shall do from here ? / Regards
can you please try to implement the UINavigationBar class and override one drawRect: method
it should work
#implementation UINavigationBar (BackgroundImage)
- (void)drawRect:(CGRect)rect
{
UIImage *navimage;
//we will check if screen width is 320 then it will be potrait
if(self.frame.size.width == 320)
{
navimage = [UIImage imageNamed: #"Your Potrait nav bar image"];
}
else
{
navimage = [UIImage imageNamed: #"Your Landscape nav bar image"];
}
[navimage drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
#end
Hope it helps...
and just try this for nr1 and nr2
just change the last line of code with this..if its working or not...let me know
self.navigationController.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; //UIViewAutoresizingFlexibleWidth

Status bar and navigation bar issue in IOS7

I am migrating my application to iOS 7. For handing the status bar issue I have added this code
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f)
{
CGRect frame = self.navigationController.view.frame;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
frame.origin.y = 20;
}
else
{
frame.origin.x = 20;
}
[self.navigationController.view setFrame:frame];
}
This is working fine in normal case. If I am changing orientation (app supports only landscape orientation) or presenting any view controller and dismissing model view controller my view controller alignment changed. The status bar again overlaps my view controller. This piece of code is not working at all. Please guide me to fix this status bar issue.
Case 2: This is how I am presenting my view controller
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
reader.supportedOrientationsMask = ZBarOrientationMaskLandscape;
else
reader.supportedOrientationsMask = ZBarOrientationMaskPortrait;
[self presentModalViewController:reader animated:YES];
Ref:
Fix for status bar issue in IOS 7
Finally I fixed the status bar over lap issue using the delta value property in xcode5. First I have increased origin - y 20pxl to all the controller used in the Xib (it seams to be working fine only in IOS 7), after that I set the delta value for all the view controller origin -y to -20 it works fine in both iOS 6 and iOS 7.
Steps to do that.
Xcode 5 provide preview option to view the appearance of the xib in different view based on the OS version.
Choose preview option from assistant editor
Click assistant editor
and choose preview option to preview selected view controller in different version.
view controller view preview option.
in preview you can find the toggle option to preview view in different version. In preview u can feel the status bar issue clearly if its not fixed properly by toggle the version.
Three steps to fix the status bar issue:
step 1: Make sure the view target us 7.0 and later in File inspector.
Step 2 : Increase the origin - y with 20 pixel (exactly the size of the status bar) for all the controls added in the view controller.
Step 3 : Set the delta value of origin y to -20 for all the controls then only it will adjust automatically based on the version. Use preview now and feel the differ that the controls automatically adjust because of the delta value.
Once the status bar issue fixed, issue while presenting the model view (ZbarSDk controller) is also fixed automatically.
Preview screen :
I am late for this Answer, but i just want to share what i did, which is basically
the easiest solution
First of all-> Go to your info.plist File and add Status Bar Style->Transparent Black Style(Alpha of 0.5)
Now ,here it Goes:-
Add this code in your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Whatever your code goes here
if(kDeviceiPad){
//adding status bar for IOS7 ipad
if (IS_IOS7) {
UIView *addStatusBar = [[UIView alloc] init];
addStatusBar.frame = CGRectMake(0, 0, 1024, 20);
addStatusBar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; //change this to match your navigation bar
[self.window.rootViewController.view addSubview:addStatusBar];
}
}
else{
//adding status bar for IOS7 iphone
if (IS_IOS7) {
UIView *addStatusBar = [[UIView alloc] init];
addStatusBar.frame = CGRectMake(0, 0, 320, 20);
addStatusBar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; //You can give your own color pattern
[self.window.rootViewController.view addSubview:addStatusBar];
}
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
[application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
self.window.clipsToBounds =YES;
self.window.frame =CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
[self.window makeKeyAndVisible];
return YES;
}
set the following to info.plist
View controller-based status bar appearance = NO;
To hide status bar in ios7 follow these simple steps :
In Xcode goto "Resources" folder and open "(app name)-Info.plist file".
check for "View controller based status bar appearance" key and set its value "NO"
check for "Status bar is initially hidden" key and set its value "YES"
If the keys are not there then you can add it by selecting "information property list" at top and click + icon
MUCH MUCH MUCH simpler answer:
Align the top of your view to the "top layout guide", but control-dragging "Top Layout Guide" to your view and setting the "vertical" constraint. See this answer for a picture reference.
The way it works is - the "Top Layout Guide" will automagically ajust itself for when the status bar is or is not there, and it will all work - no coding required!
P.S. In this particular example, the background showing through at the bottom should also be resolved by setting an appropriate vertical constraint of the view's bottom, to it's superview, or whatever...
Hear we can do this for all views at once
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Notification for the orientaiton change
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(applicationDidChangeStatusBarOrientation:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
// Window framing changes condition for iOS7 or greater
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
statusBarBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, self.window.frame.size.width, 20)];//statusBarBackgroundView is normal uiview
statusBarBackgroundView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.730];
[self.window addSubview:statusBarBackgroundView];
self.window.bounds = CGRectMake(0, -20, self.window.frame.size.width, self.window.frame.size.height);
}
// Window framing changes condition for iOS7 or greater
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
And While we are using orientation we can add below method in app delegate to set it via orientation.
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
statusBarBackgroundView.hidden = YES;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
int width = [[UIScreen mainScreen] bounds].size.width;
int height = [[UIScreen mainScreen] bounds].size.height;
switch (orientation) {
case UIInterfaceOrientationLandscapeLeft:
self.window.bounds = CGRectMake(-20,0,width,height);
statusBarBackgroundView.frame = CGRectMake(-20, 0, 20, height);
break;
case UIInterfaceOrientationLandscapeRight:
self.window.bounds = CGRectMake(20,0,width,height);
statusBarBackgroundView.frame = CGRectMake(320, 0, 20, height);
break;
case UIInterfaceOrientationPortraitUpsideDown:
statusBarBackgroundView.frame = CGRectMake(0, 568, width, 20);
self.window.bounds = CGRectMake(0, 20, width, height);
break;
default:
statusBarBackgroundView.frame = CGRectMake(0, -20, width, 20);
self.window.bounds = CGRectMake(0, -20, width, height);
break;
}
statusBarBackgroundView.hidden = NO;
}
}
You should Add below navigation controller category for it
.h
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#interface UINavigationController (iOS6fix)
#end
.m
#import "UINavigationController+iOS6fix.h"
#implementation UINavigationController (iOS6fix)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
#end
With Salesforce SDK 2.1 (Cordova 2.3.0) we had to do the following to get the status bar appear on the initial load of the App and coming back from the background (iPhone and iPad):
Contrarily to other solutions posted here, this one seems to survive rotation of the device.
1-Create a category of theSFHybridViewController
#import "SFHybridViewController+Amalto.h"
#implementation SFHybridViewController (Amalto)
- (void)viewWillAppear:(BOOL)animated
{
//Lower screen 20px on ios 7
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = self.view.bounds;
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
}
[super viewWillAppear:animated];
}
- (void)viewDidLoad
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = self.view.bounds;
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
}
[super viewDidLoad];
}
#end
2-Add to AppDelegate.m imports
#import "SFHybridViewController+Amalto.h"
3-Inject at the end of of method didFinishLaunchingWithOptions of AppDelegate
//Make the status bar appear
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
[application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
4-Add to App-Info.plist the property
View controller-based status bar appearance with value NO
i solved this by using below code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if(landScape mode)
if ([UIDevice currentDevice].systemVersion.floatValue>=7) {
CGRect frame = self.window.frame;
frame.size.width -= 20.0f;
frame.origin.x+= 20.0f;
self.window.frame = frame;
}
if(portrait)
if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
CGRect frame = self.window.frame;
frame.origin.y += 20.0f;
frame.size.height -= 20.0f;
self.window.frame = frame;
}
return YES;
}
#define _kisiOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
if (_kisiOS7)
{
[[UINavigationBar appearance] setBarTintColor:_kColorFromHEX(#"#011C47")];
}
else
{
[[UINavigationBar appearance] setBackgroundColor:_kColorFromHEX(#"#011C47")];
[[UINavigationBar appearance] setTintColor:_kColorFromHEX(#"#011C47")];
}
There are several different ways. One approach is to use .plist file
Add a new key "View controller-based status bar appearance" and set value as "NO".
Add another key "Status bar is initially hidden" and set value as "YES".
This will hide status bar throughout project.
just set the following code in viewWillAppear.
if ([[[UIDevice currentDevice] systemVersion] floatValue]<= 7) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}

UIPopoverController frame overlapping its contentView's UINavigationBar

Any idea how to shift the navbar view so I have the expected padding? It looks like the popover frame is overlapped on the nav bar's top, left and right side.
This is my nav controller in a popover controller derived from the app's root splitViewController. It's an issue on < iOS 5.1
The solution is to remove the custom UINavigationBar styling when in a UIPopoverController. I'll post the implementation when it's ready.
Update
So this is a funny one. iOS 4.x and iOS 5.0 use a real, genuine popover, that is the floating popover. Custom navigation bars don't work in this popover (navBar setBackgroundImage in iOS 5.0 and the category drawRect override in iOS 4.x).
However, 5.1 uses more of a "slideover," where the custom navbar works nicely. It's a much cleaner design actually.
Anyway, my point is that now I need to remove the custom navBar formatting only when in portrait AND the OS is less than 5.1. Normally, you'd want to use respondsToSelector in lieu of manually figuring out an OS version. That doesn't work in this case.
Still working on the iOS 4.x fix, but here's iOS 5.0:
In my appDelete, where I set up the custom navBar:
//iOS 5.x:
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)])
{
UIImage *image = [UIImage imageNamed:#"header.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
//iOS 4.x:
#implementation UINavigationBar (CustomBackground)
- (void)drawRect:(CGRect)rect
{
UIImage *image = [UIImage imageNamed:#"header.png"];
[image drawInRect:CGRectMake(0, 0, 320, 44)];
}
#end
I set up an observer in didFinishLaunching:
//start orientation notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(didRotate:)
name:#"UIDeviceOrientationDidChangeNotification"
object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
- (void) didRotate:(NSNotification *)notification
{
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version < 5.1)
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (UIDeviceOrientationIsPortrait(orientation))
{
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)])
{
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
}
}
else
{
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)])
{
UIImage *image = [UIImage imageNamed:#"header.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
}
}
}

custom UINavigation bar in iOS5

I am having troubles after updating to Xcode 4.2.
Before I used the following codes for making custom navigation bar, but when i use iPhone 5.0 simulator, it fails whereas in iPhone 4.2 simulator it was ok.
May I know what is the problem and how can i fix this?
Many thanks
#implementation UINavigationBar (UINavigationBarCustomDraw)
- (void) drawRect:(CGRect)rect {
[self setTintColor:[UIColor colorWithRed:0.4f
green: 0.0f
blue:0.4f
alpha:1]];
if ([self.topItem.title length] > 0 && ![self.topItem.title isEqualToString:#""])
{
[[UIImage imageNamed:#"purple.jpg"] drawInRect:rect];
}
}
#end
If you need custom UINavigationbar with some image so you need to put this code in rootViewController that is first view of navigate stack (A > B > C , so you have to put this in A)
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] systemVersion];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
//iOS 5
UIImage *toolBarIMG = [UIImage imageNamed: #"purple.jpg"];
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)]) {
[[UINavigationBar appearance] setBackgroundImage:toolBarIMG forBarMetrics:UIBarMetricsDefault];
}
} else {
//iOS 4
[self.navigationController.navigationBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"purple.jpg"]] autorelease] atIndex:0];
}
}
}

iPad, Resize custom button in viewForHeaderInSection

My application has splitview and it's activated only in landscape mode.
In masterview i have tableview and in the last section i have a custom button.
The problem is that the button width stays in potrait instead of using device orientation.
I've tried to play with setAutoresizingMask on button and view but that doesn't work either.
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger) sectionNum {
if (sectionNum == 4) {
CGRect frameSize;
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
frameSize = CGRectMake(45.0, 0.0, 600.0, 44.0);
} else {
frameSize = CGRectMake(45.0, 0.0, 680.0, 44.0);
}
UIView *btnView = [[[UIView alloc] initWithFrame:frameSize] autorelease];
// button
UIButton* btnFind = [UIButton buttonWithType:UIButtonTypeCustom];
[btnFind setBackgroundImage:[[UIImage imageNamed:#"buttonblue.png"] stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0] forState:UIControlStateNormal];
[btnFind setBackgroundImage:[[UIImage imageNamed:#"buttonred.png"] stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0] forState:UIControlStateHighlighted];
btnFind.frame = frameSize;
btnFind.tag = 1;
[btnFind setTitle:#"Find" forState:UIControlStateNormal];
[btnFind addTarget:self action:#selector(doSearchDoc:) forControlEvents:UIControlEventTouchUpInside];
//[btnFind setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
//[btnView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[btnView addSubview:btnFind];
return btnView;
}
return nil;
}
Can someone please let me know how to resolve this.
Thanks.
I've had other issues that the header was not refreshed when rotating the device, ie. the method above was not invoked in my situatio, you could check if this is the case also for you.
The solution I adopted was to invoke reloadData in the rotating method :
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// This solves an issue that the header doesn't show when roating device (ok on simulator)
NSIndexPath* ipselected = [self.tableView indexPathForSelectedRow];
[self.tableView reloadData];
[self.tableView selectRowAtIndexPath:ipselected animated:false scrollPosition:UITableViewScrollPositionMiddle];
}
Of course it is usable if you can afford a full reload when rotating the device but itis typically a time when the user will better accept a 0.5s delay as he/she is busy with moving the device.
lternatively you could keep an ivar to your button and change its frame in the above method.

Resources