Git Product home page Git Product logo

xiaopohou / cjnewsorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dvlproad/cjnewsorder

0.0 2.0 0.0 484 KB

实现了凤凰新闻的频道订阅界面和功能,点击某个频道,可以将其移入或者移出订阅栏,剩下的频道自动重新排列。归档Model数组到本地app的Library文件夹。(参考http://code4app.com/ios/ifengNewsOrderDemo/53159e83933bf0473e8b5d08)

License: MIT License

Ruby 1.85% Objective-C 98.15%

cjnewsorder's Introduction

CJNewsOrder

实现了凤凰新闻的频道订阅界面和功能,点击某个频道,可以将其移入或者移出订阅栏,剩下的频道自动重新排列。归档Model数组到本地app的Library文件夹。(参考http://code4app.com/ios/ifengNewsOrderDemo/53159e83933bf0473e8b5d08)

Screenshots

Example

How to use

  • ①、ChannelOrderVC的使用
//初始化如下:
#pragma mark - 类似网易新闻的订阅功能
- (IBAction)show_orderView:(id)sender{
    CGFloat y = 64;
    CGFloat width = self.view.bounds.size.width;
    CGFloat height = self.view.bounds.size.height - y;
    CGRect rect_hidden = CGRectMake(0, - height, width, height);
    CGRect rect_show = CGRectMake(0, y, width, height);

    ChannelOrderVC *orderVC = [[ChannelOrderVC alloc] init];
    orderVC.dataSource = self;
    orderVC.delegate = self;
    [orderVC.view setFrame:rect_hidden]; //注意点:setFrame要在此view被addSubview之前调用
    [self.view addSubview:orderVC.view];
    [self addChildViewController:orderVC];
    [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionLayoutSubviews animations:^{
    [orderVC.view setFrame:rect_show];
    
    } completion:^(BOOL finished){
    
    }];
}

#pragma mark 数据源:ChannelOrderVCDataSource
- (NSMutableArray *)originChannelOrderYES_whenChannelFileNoExist{
    NSArray *channelNames = [NSArray arrayWithObjects:KChannelList, nil] ;
    NSArray *channelUrls = [NSArray arrayWithObjects:KChannelUrlStringList, nil];

    NSMutableArray *channel_order_YES_Ori = [NSMutableArray array]; //Origin
    for (int i = 0; i < channelNames.count; i++) {
        NSString *channelName = [channelNames objectAtIndex:i];
        NSString *channelUrl = [channelUrls objectAtIndex:i];
        ChannelModel *channel = [[ChannelModel alloc]initWithTitle:channelName urlString:channelUrl];
        if (i < KDefaultCountOfUpsideList - 1) {
            [channel_order_YES_Ori addObject:channel];
        }
    }
    return channel_order_YES_Ori;
}

- (NSMutableArray *)originChannelOrderNO_whenChannelFileNoExist{
    NSArray *channelNames = [NSArray arrayWithObjects:KChannelList, nil] ;
    NSArray *channelUrls = [NSArray arrayWithObjects:KChannelUrlStringList, nil];

    NSMutableArray *channel_order_NO_Ori = [NSMutableArray array];
    for (int i = 0; i < channelNames.count; i++) {
        NSString *channelName = [channelNames objectAtIndex:i];
        NSString *channelUrl = [channelUrls objectAtIndex:i];
        ChannelModel *channel = [[ChannelModel alloc]initWithTitle:channelName urlString:channelUrl];
        if (i >= KDefaultCountOfUpsideList - 1) {
            [channel_order_NO_Ori addObject:channel];
        }
    }
    return channel_order_NO_Ori;
}

#pragma mark 委托:ChannelOrderVCDelegate
- (void)hiddenChannelOrderVC:(ChannelOrderVC *)orderVC{
    if (orderVC->_viewArr1.count < 3) {
        [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"提示", nil)
                                   message:NSLocalizedString(@"请至少选择三个", nil)
                                  delegate:nil
                         cancelButtonTitle:NSLocalizedString(@"确定", nil)
                         otherButtonTitles:nil] show];
        return;
    }

    [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionLayoutSubviews animations:^{
        CGFloat width = self.view.bounds.size.width;//本例中orderButton.vc等于self
        CGFloat height = self.view.bounds.size.height;
        CGRect rect_hidden = CGRectMake(0, - height, width, height);
        [orderVC.view setFrame:rect_hidden];

    } completion:^(BOOL finished){
        [orderVC updateCurrentOrder_whenChangeOrder];

        [orderVC.view removeFromSuperview];
        [orderVC removeFromParentViewController];

    }];
}
  • ②、xxxx的使用

  • ③、xxxx的使用

cjnewsorder's People

Contributors

dvlproad avatar

Watchers

James Cloos avatar 老赵 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.