1

当用户单击按钮时,我想实现可扩展表,自动在同一视图中打开另一个表。

这是我的 .m 文件strong text

#import "MenuVc.h"
#import "Reachability.h"
#import "YRDropdownView.h"
#import "MenuFirstCell.h"

@interface MenuVc ()

@end

@implementation MenuVc

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    menuArr=[[NSMutableArray alloc]init];
     fvd=[[NSMutableArray alloc]init];
     secondNEw=[[NSMutableArray alloc]init];
  //  [self.firstmenutble registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

      [self.firstmenutble registerNib:[UINib nibWithNibName:@"MenuFirstCell" bundle:nil] forCellReuseIdentifier:@"Cell"];

    [self countries_delay];


    _sub_menu=[[Submenu alloc]initWithNibName:@"Submenu" bundle:nil];

    [self.view addSubview:_sub_menu.view];
    _sub_menu.delegate=self;
    _sub_menu.view.hidden=YES;
    self.sub_menu.view.frame = CGRectMake(156, 45,156 , 317);
    [self.view addSubview:self.sub_menu.view];



    //[self netcheck];
}




- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {


    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return menuArr.count;

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    MenuFirstCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];




      //  UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

        cell.name.text=[[menuArr objectAtIndex:indexPath.row] objectForKey:@"name"];
        cell.name.font =[UIFont fontWithName:@"PT Sans" size:14];
    cell.nextbtn.tag = indexPath.row;
    [cell.nextbtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

        return cell;

    }







- (IBAction)btnClick:(id)sender
{


//    
//    if (self.sub_menu.view.frame.origin.x == 156)
//    {
//                    _sub_menu.view.hidden=NO;
//            //
//            //    CATransition *applicationLoadViewIn = [CATransition animation];
//            //    //
//            //       [applicationLoadViewIn setDuration:0.5];

这是我的 .h 文件-

#import "Submenu.h"
#import <UIKit/UIKit.h>
@protocol Scrap_menuDelegate <NSObject>
-(void)HomeBtn;
@end
@interface MenuVc : UIViewController<UITableViewDataSource, UITableViewDelegate,submenu_menuDelegate>
{

    NSMutableArray *menuArr;


    IBOutlet UIActivityIndicatorView *activityView;

      NSMutableArray *fvd;
    NSMutableArray *secondNEw;

}
@property(weak,nonatomic)id delegate;


@property(nonatomic, strong) Submenu *sub_menu;


@property (strong, nonatomic) IBOutlet UIView *firstview;
@property (strong, nonatomic) IBOutlet UITableView *firstmenutble;



- (IBAction)HomeBtn:(id)sender;

@end

请使用此代码扩展表实现。

4

0 回答 0