ios 下拉列表被tableview挡住了要怎么把下拉列表显示出来
推荐于2016-12-03 · 知道合伙人软件行家
关注
展开全部
楼主你好!根据你的描述,让我来给你回答!
// DDIUICtrl_Message.m
// DDInsurance
//
// Created by LeeYunHeNB on 14-9-26.
// Copyright (c) 2014年 XinMaHuTong. All rights reserved.
//
#import "DDIUICtrl_Message.h"
#import "DDIUICtrl_messageCell.h"
#import "DDUICtrl_menuCell.h"
@interface DDIUICtrl_Message ()
@property (weak, nonatomic) IBOutlet UITableView *my_tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;
@property (assign)BOOL isOpen;
@end
@implementation DDIUICtrl_Message
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setTitle:@"我的消息"];
[self setLeftButtonText:@"" andBackground:[UIImage imageNamed:@"btn_back"]];
NSDictionary *dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};
NSArray * array = @[dic,dic,dic,dic,dic,dic];
self.dataArray = [[NSMutableArray alloc]init];
self.dataArray = [NSMutableArray arrayWithArray:array];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.dataArray.count;;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
// tableViewCell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"])
{
static NSString *CellIdentifier = @"MainCell";
DDIUICtrl_messageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[DDIUICtrl_messageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
// cell.Headerphoto.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",indexPath.row%4+1]];
return cell;
}else if([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"AttachedCell"]){
static NSString *CellIdentifier = @"AttachedCell";
DDUICtrl_menuCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[DDUICtrl_menuCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
return nil;
}
// tableView点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSIndexPath *path = nil;
if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"]) {
path = [NSIndexPath indexPathForItem:(indexPath.row+1) inSection:indexPath.section];
}else{
path = indexPath;
}
if ([[self.dataArray[indexPath.row] objectForKey:@"isAttached"] boolValue]) {
// 关闭附加cell
NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};
self.dataArray[(path.row-1)] = dic;
[self.dataArray removeObjectAtIndex:path.row];
[self.my_tableView beginUpdates];
[self.my_tableView deleteRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];
[self.my_tableView endUpdates];
}else{
// 打开附加cell
NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(YES)};
self.dataArray[(path.row-1)] = dic;
NSDictionary * addDic = @{@"Cell": @"AttachedCell",@"isAttached":@(YES)};
[self.dataArray insertObject:addDic atIndex:path.row];
[self.my_tableView beginUpdates];
[self.my_tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];
[self.my_tableView endUpdates];
}
}
@end
希望能帮到你,如果满意,请记得采纳哦~~~
// DDIUICtrl_Message.m
// DDInsurance
//
// Created by LeeYunHeNB on 14-9-26.
// Copyright (c) 2014年 XinMaHuTong. All rights reserved.
//
#import "DDIUICtrl_Message.h"
#import "DDIUICtrl_messageCell.h"
#import "DDUICtrl_menuCell.h"
@interface DDIUICtrl_Message ()
@property (weak, nonatomic) IBOutlet UITableView *my_tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;
@property (assign)BOOL isOpen;
@end
@implementation DDIUICtrl_Message
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setTitle:@"我的消息"];
[self setLeftButtonText:@"" andBackground:[UIImage imageNamed:@"btn_back"]];
NSDictionary *dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};
NSArray * array = @[dic,dic,dic,dic,dic,dic];
self.dataArray = [[NSMutableArray alloc]init];
self.dataArray = [NSMutableArray arrayWithArray:array];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.dataArray.count;;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
// tableViewCell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"])
{
static NSString *CellIdentifier = @"MainCell";
DDIUICtrl_messageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[DDIUICtrl_messageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
// cell.Headerphoto.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",indexPath.row%4+1]];
return cell;
}else if([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"AttachedCell"]){
static NSString *CellIdentifier = @"AttachedCell";
DDUICtrl_menuCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[DDUICtrl_menuCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
return nil;
}
// tableView点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSIndexPath *path = nil;
if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"]) {
path = [NSIndexPath indexPathForItem:(indexPath.row+1) inSection:indexPath.section];
}else{
path = indexPath;
}
if ([[self.dataArray[indexPath.row] objectForKey:@"isAttached"] boolValue]) {
// 关闭附加cell
NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};
self.dataArray[(path.row-1)] = dic;
[self.dataArray removeObjectAtIndex:path.row];
[self.my_tableView beginUpdates];
[self.my_tableView deleteRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];
[self.my_tableView endUpdates];
}else{
// 打开附加cell
NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(YES)};
self.dataArray[(path.row-1)] = dic;
NSDictionary * addDic = @{@"Cell": @"AttachedCell",@"isAttached":@(YES)};
[self.dataArray insertObject:addDic atIndex:path.row];
[self.my_tableView beginUpdates];
[self.my_tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];
[self.my_tableView endUpdates];
}
}
@end
希望能帮到你,如果满意,请记得采纳哦~~~
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询