欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

IOS7相关问题记录

程序员文章站 2022-05-28 22:54:06
...

如果使用nav 则很容易与内容值重叠,因此,需要增加这几行代码。关键是这句

self.edgesForExtendedLayout = UIRectEdgeNone;

表示将IOS边框扩展设置为none

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    if ([CommonUtil systemVersion] >= 7) {

        CGRect frame=self.view.frame;

        if (frame.size.height==[[NSUserDefaults standardUserDefaults] floatForKey:@"windowHeight"])

        {

            frame.size.height-=20;

        }

        self.view.frame=frame;

        self.edgesForExtendedLayout = UIRectEdgeNone;

        self.automaticallyAdjustsScrollViewInsets = YES;

        self.navigationController.navigationBar.translucent = NO;

        self.tabBarController.tabBar.translucent = NO;

    }

}

------------------

通过cell去找indexPath的方法,原来是这样

 

SDGroupCell *cell = (SDGroupCell *)[(UIView *)[sender superview] 

 

NSIndexPath *indexPath = [self.baseTableView indexPathForCell:cell];

但实际上,IOS貌似不支持这样查询,要查的话用以下方式

UIView *view = sender;

    while (![view isKindOfClass:[UITableViewCell class]]) {

        view = [view superview];

}

 

    NSIndexPath *indexPath = [self.baseTableView indexPathForCell:(UITableViewCell *)view];

-----------------

 

http://*.com/questions/19355182/sdnestedtable-expand-does-not-work-on-ios-7/19355366#19355366

原来的SDNestedTable的工具类,由于在初次进去的时候无法很好地进行展开cell里的隐藏位置,升到IOS7无法使用,因此要进行修改(红色字):

//The issue is that expanded index paths are stored in NSDictionary, where NSIndexPath is key. In iOS 7 method -(CGFloat)tableView:heightForRowAtIndexPath: receivesUIMutableIndexPath object instead of NSIndexPath object. So value from dictionary can't be retrieved. Here is this method in SDNestedTableViewController.m:

 

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //IOS7 的处理是先获取NSIndexPath 的key 因为在字典里找不到,因此要这样做

 

     NSIndexPath *indexPathKey = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];

   BOOL isExpanded = [[expandedIndexes objectForKey: indexPath] boolValue];

    if(isExpanded)

    {

        //第一次进入时,先看cell的大小是否合适

        if(itemCellButtonFisrtDrop == 0){

            [self getCellButtonHeight:indexPathKey];

            itemCellButtonFisrtDrop ++;

        }

        return [self geTotleCelltHeight] + 1+30+itemCellButtonViewHeight;

    }

    return [self geCelltHeight];

    

-----------------

原来不用加红色这段,都能有导航出来,现在可能要加了

 UINavigationController *nav = [[UINavigationControlleralloc]initWithRootViewController:userBillRequestVC];

    if ([[UIDevicecurrentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

    {

        [selfpresentModalViewController:nav animated:YES];

 

    }

------------------

uisearchbar 中的层次结构变化了,原来IOS7之前是UISearchBar的subviews是UISearchBarBackground、UISearchBarTextField。而现在IOS7却只有一个uiview,仔细再观察这个uiView,发现苹果将UISearchBarBackground、UISearchBarTextField都封装在一个UIView里,因此,如果要改变其背景图片,可以用以下方法:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {

                

                subviews = [[billSearchBar.subviews objectAtIndex:0] subviews];

                

            }else{

                

                subviews = billSearchBar.subviews;

                

            }

            for (UIView *subview in subviews)

            {  

                if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])

                {  

                    [subview removeFromSuperview];  

                    break;  

                }  

            }

            

            [searchToolBar addSubview:billSearchBar];

            //为UISearchBarTextField设置背景图片

            UIView *segment = [subviews count]>0 ? [subviews objectAtIndex:1]: [subviews objectAtIndex:0];

            

            UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search_bar_text_bg"]];

 

            [segment addSubview:bgImage];