Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

类型问题 #1

Open
al1020119 opened this issue Aug 29, 2016 · 1 comment
Open

类型问题 #1

al1020119 opened this issue Aug 29, 2016 · 1 comment

Comments

@al1020119
Copy link

如果我的控制器是UItableViewController呢?或者说需要设置tableView的heander,和Sectionheader这样的话是否需要修改源码处理?

@yizzuide
Copy link
Owner

yizzuide commented Aug 29, 2016

@al1020119

问题一,如果我的控制器是UITableViewController

如果当前已经有一个写好的设置界面继承自UITableViewController

非常抱歉,本框架是没有考虑为旧项目动态添加设置行的功能,只有新项目适合用,或者用本框架重写?因为本人就是每到一家公司去,就会用本框架重写,毕竟设置界面没有多少代码,重写的原因是,旧项目很多设置界面是这么写的:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 太多魔法数字,看得头晕
    if(indexPath.section == 0){
        if(indexPath.row == 0){
             // 跳转到一个控制器
        }else if(indexPath.row == 1){
            // 跳转到另一个控制器
       }
    }
    // 。。。其它section和row的情况等等
}

如果是一个新类要做设置界面已继承自UITableViewController

把它改为继承普通的UIViewController,然后导入本框架的UIViewController+XFSettings.h,其步骤请参考快速开始使用文档

问题二,需要设置tableView的header

这个不需要修改源码,可以直接在控制器viewDidLoad方法里设置self.xf_tableView.tableHeaderView=你的列表头视图,例如:

   UIView *headerParentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 88)];
    headerParentView.backgroundColor = UIColorFromRGB(CBBackgroundColor);
    XFSettingHeaderView *settingHeaderView = [XFSettingHeaderView settingHeaderView];
    settingHeaderView.size = CGSizeMake(self.view.width, 88);
    [headerParentView addSubview:settingHeaderView];
    self.settingHeaderView = settingHeaderView;
    self.xf_tableView.tableHeaderView = headerParentView;

问题三、添加SectionHeader视图

这个确实是要修改源码核心内容,因为这是没有考虑在内的,我看过很多设置界面,没有要自定义SectionHeader视图的,如果方便的话,可以发邮件到fu837014586@163.com,并附上你的设置界面样图。

非常感谢你的提问,希望对你有所帮助。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants