求各位酷派大神2帮忙,下面这个通讯组内数量显示null是怎么回事???

iOS 问题:求大神们帮我看看,这段代码哪里出问题了,我要在点击button后出现下拉菜单,选择后,文字出现在button的title上 ,可是现在点击button崩溃,崩溃原因'Requesting the window of a view (&NIDropDown: 0x; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)&) with a nil layer. This view probably hasn't received initWithFrame: or initWithCoder:.'
我是参照这个demo做的/ios/NIDropDown/50fe226e00000,我和这个demo唯一的区别就是,他是nib中添加的button,我是在故事板中。。。。从崩溃原因上看,我可能是哪里没初始化,我是超新手,不懂,求大神门仔细看看,谢谢啦,下面上代码:
#import "NIDropDown.h"
#import "QuartzCore/QuartzCore.h"
@interface NIDropDown ()
@property(nonatomic, strong) UITableView *
@property(nonatomic, strong) UIButton *btnS
@property(nonatomic, retain) NSArray *
@implementation NIDropDown
@synthesize btnS
- (id)showDropDown:(UIButton *)b:(CGFloat *)height:(NSArray *)arr {
btnSender =
if (self) {
// Initialization code
CGRect btn = b.
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
self.list = [NSArray arrayWithArray:arr];
self.layer.masksToBounds = NO;
self.layer.cornerRadius = 8;
self.layer.shadowOffset = CGSizeMake(-5, 5);
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = 0.5;
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, btn.size.width, 0)];
table.delegate =
table.dataSource =
table.layer.cornerRadius = 5;
table.backgroundColor = [UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1];
table.separatorStyle = UITableViewCellSeparatorStyleSingleL
table.separatorColor = [UIColor grayColor];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, *height);
table.frame = CGRectMake(0, 0, btn.size.width, *height);
[UIView commitAnimations];
[b.superview addSubview:self];
[self addSubview:table];
-(void)hideDropDown:(UIButton *)b {
CGRect btn = b.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
table.frame = CGRectMake(0, 0, btn.size.width, 0);
[UIView commitAnimations];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.list count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.font = [UIFont systemFontOfSize:15];
cell.textLabel.textAlignment = UITextAlignmentC
cell.textLabel.text =[list objectAtIndex:indexPath.row];
cell.textLabel.textColor = [UIColor blackColor];
UIView * v = [[UIView alloc] init];
v.backgroundColor = [UIColor grayColor];
cell.selectedBackgroundView =
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self hideDropDown:btnSender];
UITableViewCell *c = [tableView cellForRowAtIndexPath:indexPath];
[btnSender setTitle:c.textLabel.text forState:UIControlStateNormal];
[self myDelegate];
- (void) myDelegate {
[self.delegate niDropDownDelegateMethod:self];
#import "ViewController.h"
#import "NIDropDown.h"
#import &QuartzCore/QuartzCore.h&
@interface ViewController ()
@implementation ViewController
@synthesize btnSelect1;
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
btnSelect1.layer.borderWidth = 1;
btnSelect1.layer.borderColor = [[UIColor blackColor] CGColor];
btnSelect1.layer.cornerRadius = 5;
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
- (void) niDropDownDelegateMethod: (NIDropDown *) sender {
[self rel];
-(void)rel{
dropDown1 =
- (IBAction)selectClicked1:(UIButton *)sender {
NSArray * arr = [[NSArray alloc] init];
arr = [NSArray arrayWithObjects:@"Hello 0", @"Hello 1", @"Hello 2", @"Hello 3", @"Hello 4", @"Hello 5", @"Hello 6", @"Hello 7", @"Hello 8", @"Hello 9",nil];
if(dropDown1 == nil) {
CGFloat f = 20.0;
//此处为崩溃的原因
dropDown1 = [[NIDropDown alloc]showDropDown:sender :&f :arr];
dropDown1.delegate =
[dropDown1 hideDropDown:sender];
[self rel];
求大神们帮我看看,这段代码哪里出问题了,我要在点击button后出现下拉菜单,选择后,文字出现在button的title上 ,可是现在点击button崩溃,崩溃原因'Requesting the window of a view (&NIDropDown: 0x; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)&) with a nil layer. This view probably hasn't received initWithFrame: or initWithCoder:.'
我是参照这个demo做的,我和这个demo唯一的区别就是,他是nib中添加的button,我是在故事板中。。。。从崩溃原因上看,我可能是哪里没初始化,我是超新手,不懂,求大神门仔细看看,谢谢啦,下面上代码:
#import "NIDropDown.h"
#import "QuartzCore/QuartzCore.h"
@interface NIDropDown ()
@property(nonatomic, strong) UITableView *
@property(nonatomic, strong) UIButton *btnS
@property(nonatomic, retain) NSArray *
@implementation NIDropDown
@synthesize btnS
- (id)showDropDown:(UIButton *)b:(CGFloat *)height:(NSArray *)arr {
btnSender =
if (self) {
// Initialization code
CGRect btn = b.
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
self.list = [NSArray arrayWithArray:arr];
self.layer.masksToBounds = NO;
self.layer.cornerRadius = 8;
self.layer.shadowOffset = CGSizeMake(-5, 5);
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = 0.5;
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, btn.size.width, 0)];
table.delegate =
table.dataSource =
table.layer.cornerRadius = 5;
table.backgroundColor = [UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1];
table.separatorStyle = UITableViewCellSeparatorStyleSingleL
table.separatorColor = [UIColor grayColor];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, *height);
table.frame = CGRectMake(0, 0, btn.size.width, *height);
[UIView commitAnimations];
[b.superview addSubview:self];
[self addSubview:table];
-(void)hideDropDown:(UIButton *)b {
CGRect btn = b.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
table.frame = CGRectMake(0, 0, btn.size.width, 0);
[UIView commitAnimations];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.list count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.font = [UIFont systemFontOfSize:15];
cell.textLabel.textAlignment = UITextAlignmentC
cell.textLabel.text =[list objectAtIndex:indexPath.row];
cell.textLabel.textColor = [UIColor blackColor];
UIView * v = [[UIView alloc] init];
v.backgroundColor = [UIColor grayColor];
cell.selectedBackgroundView =
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self hideDropDown:btnSender];
UITableViewCell *c = [tableView cellForRowAtIndexPath:indexPath];
[btnSender setTitle:c.textLabel.text forState:UIControlStateNormal];
[self myDelegate];
- (void) myDelegate {
[self.delegate niDropDownDelegateMethod:self];
#import "ViewController.h"
#import "NIDropDown.h"
#import &QuartzCore/QuartzCore.h&
@interface ViewController ()
@implementation ViewController
@synthesize btnSelect1;
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
btnSelect1.layer.borderWidth = 1;
btnSelect1.layer.borderColor = [[UIColor blackColor] CGColor];
btnSelect1.layer.cornerRadius = 5;
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
- (void) niDropDownDelegateMethod: (NIDropDown *) sender {
[self rel];
-(void)rel{
dropDown1 =
- (IBAction)selectClicked1:(UIButton *)sender {
NSArray * arr = [[NSArray alloc] init];
arr = [NSArray arrayWithObjects:@"Hello 0", @"Hello 1", @"Hello 2", @"Hello 3", @"Hello 4", @"Hello 5", @"Hello 6", @"Hello 7", @"Hello 8", @"Hello 9",nil];
if(dropDown1 == nil) {
CGFloat f = 20.0;
//此处为崩溃的原因
dropDown1 = [[NIDropDown alloc]showDropDown:sender :&f :arr];
dropDown1.delegate =
[dropDown1 hideDropDown:sender];
[self rel];
共有 1 个回答
闲着没事新建了一个工程看了下你的代码 运行正常 最好是你把工程发到一个地方可以下载看看
登录后方可回复
登录后方可回答
耗时 0.0578 秒求大神帮忙解决,速度。。。_c程序吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:2,144贴子:
求大神帮忙解决,速度。。。收藏
1、熟悉结构体中成员函数的使用(链表操作)。/*阅读并完善以下链表的操作函数*/#include &iostream&struct node
//节点{node *};struct list{node *
//头节点,链表只要保留头节点,通过头节点能依次找到后续节点void Initial();void Create();
//创建链表bool Empty()
//判断链表是否为空void InsertLast(const int e);
//从尾部插入一个元素void InsertFirst(const int e);
//从头部插入一个元素void DeleteFirst();
//从头删除一个元素void DeleteLast();
//从尾删除元素void Display()
//显示链表node* GetNode(int i);
//返回第i个节点void Reverse();
//链表逆置bool Find(const int e);
//在链表中查找某个值void Destroy();};void list::Initial()
//初始化,创建只有head的空节点{head=head-&next=NULL;}void list::Create()
//从head开始创建链表{
node *p,*q;
q=cout&&&请输入值(按'ctrl+z'停止): &;while(cin&&q-&data){
/* 填写语句完成操作 */}p-&next=NULL;}bool list::Empty()
{return (head-&next==NULL);}void list::InsertFirst(const int e){node *p=/* 填写语句完成操作 */head-&next=p;}void list::InsertLast(const int e){node *p,*q;p=q=q-&data=e;while(p-&next){
/* 填写语句完成操作 */}p-&next=q;q-&next=NULL;}void list::DeleteFirst(){
/* 填写语句完成操作 */}void list::DeleteLast(){/* 填写语句完成操作 */}void list::Display() const
//显示链表{/* 填写语句完成操作 */}node* list::GetNode(int i)
//返回第i个节点{int k=0;node *p;p=while(p && k&i){/* 填写语句完成操作 */}}void list:: Reverse()
//链表逆置{node *p,*q;p=head-&int count=0;while(p)
//求链表的长度{
/* 填写语句完成操作 */}int i,j;i=1;j=while(i&=count/2 && j&=count/2){
/* 填写语句完成操作 */}}bool list::Find(const int e)
//在链表中查找某个值{bool flag=node *p;p=head-&while(p){/* 填写语句完成操作 */}} void list::Destroy(){node *p;while(head){ /* 填写语句完成操作 */}}int main(){ilist.Initial();
//初始化链表,创建只有head的空节点ilist.Create();
//创建链表ilist.Display();
//输出链表cout&&ilist.InsertFirst(123); //从头插入一个值ilist.InsertLast(456); //从尾插入一个值ilist.Display();cout&&if(ilist.Find(123))
cout&&&123 在链表中&&&else
cout&&&123 不在链表中&&&ilist.DeleteFirst();
//从头删除一个值ilist.DeleteLast();
//从尾删除一个值ilist.Display();cout&&ilist.Reverse();
//逆序ilist.Display();ilist.Destroy();cout&&system(&pause&);return 0;}
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或后使用快捷导航没有帐号?
一步搞定
只需一步,快速开始
查看: 6066|回复: 44
积分2574在线时间1836 小时分享阅读权限40主题UID2357164帖子精华0 战斗力0 点 技术0 点 金币959 元 人气13 点 贡献1179 点注册时间最后登录
, 积分 2574, 距离下一级还需 426 积分
金币959 元
机子刷机过后,貌似没有备份EFS,所以刷完没信号,设置一看,基带显示未知,IMEI显示null。。。。。。。我该怎么破啊大神们,求搭救!!!!!!!
积分18008在线时间6744 小时分享阅读权限180主题UID3157480帖子精华2 战斗力25 点 技术442 点 金币2141 元 人气3808 点 贡献11454 点 手机三星 I9308注册时间最后登录
★三星扫地滴★
金币2141 元 手机三星 I9308
找人家备份的efs恢复看
积分2617在线时间97 小时分享阅读权限1主题UID8543502帖子精华0 战斗力0 点 技术0 点 金币229 元 人气0 点 贡献4195 点注册时间最后登录
头像被屏蔽
金币229 元
提示: 作者被禁止或删除 内容自动屏蔽
积分1521在线时间68 小时分享阅读权限1主题UID8575596帖子精华0 战斗力0 点 技术0 点 金币168 元 人气0 点 贡献2097 点注册时间最后登录
头像被屏蔽
金币168 元
提示: 作者被禁止或删除 内容自动屏蔽
积分549在线时间251 小时分享阅读权限20主题UID6651370帖子精华0 战斗力0 点 技术3 点 金币1148 元 人气36 点 贡献428 点注册时间最后登录
, 积分 549, 距离下一级还需 151 积分
金币1148 元
积分1751在线时间66 小时分享阅读权限1主题UID8547707帖子精华0 战斗力0 点 技术0 点 金币567 元 人气0 点 贡献2517 点注册时间最后登录
头像被屏蔽
金币567 元
提示: 作者被禁止或删除 内容自动屏蔽
积分445在线时间31 小时分享阅读权限20主题UID8581306帖子精华0 战斗力0 点 技术0 点 金币635 元 人气0 点 贡献595 点注册时间最后登录
, 积分 445, 距离下一级还需 255 积分
金币635 元
新手学习,感谢楼主分享!!!!!
积分1049在线时间0 小时分享阅读权限1主题UID8575803帖子精华0 战斗力0 点 技术0 点 金币1764 元 人气0 点 贡献1747 点注册时间最后登录
头像被屏蔽
金币1764 元
提示: 作者被禁止或删除 内容自动屏蔽
积分958在线时间31 小时分享阅读权限30主题UID8580412帖子精华0 战斗力0 点 技术0 点 金币1560 元 人气0 点 贡献1544 点注册时间最后登录
, 积分 958, 距离下一级还需 242 积分
金币1560 元
谢谢楼主分享 找了好久 谢谢哦!!!
积分2617在线时间97 小时分享阅读权限1主题UID8543502帖子精华0 战斗力0 点 技术0 点 金币229 元 人气0 点 贡献4195 点注册时间最后登录
头像被屏蔽
金币229 元
提示: 作者被禁止或删除 内容自动屏蔽
巨蟹座勋章,申请勋章需要扣除200金币
十二生肖-卯兔
十二生肖-卯兔勋章,申请勋章需要扣除200金币
安智分类版主勋章
安智分类版主勋章
安智全勤勋章
签到满一百天即可申请
安智伯乐勋章
推荐5个版主并且全部转正后可申请
安智网友聚会勋章
安智历届网友聚会勋章
参加论坛举报违规活动所得
1000万会员勋章
1000万会员勋章
Powered bySAPI 里的speak问题,求各位大神帮帮忙。谢谢!
[问题点数:50分,结帖人Ryudo9013]
SAPI 里的speak问题,求各位大神帮帮忙。谢谢!
[问题点数:50分,结帖人Ryudo9013]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2013年4月 VC/MFC大版内专家分月排行榜第一2007年7月 VC/MFC大版内专家分月排行榜第一2007年5月 VC/MFC大版内专家分月排行榜第一2007年4月 VC/MFC大版内专家分月排行榜第一2007年3月 VC/MFC大版内专家分月排行榜第一
2013年3月 VC/MFC大版内专家分月排行榜第二2013年2月 VC/MFC大版内专家分月排行榜第二2008年8月 VC/MFC大版内专家分月排行榜第二2008年7月 VC/MFC大版内专家分月排行榜第二2007年9月 VC/MFC大版内专家分月排行榜第二2007年8月 VC/MFC大版内专家分月排行榜第二2005年12月 VC/MFC大版内专家分月排行榜第二2005年10月 VC/MFC大版内专家分月排行榜第二
2013年4月 VC/MFC大版内专家分月排行榜第一2007年7月 VC/MFC大版内专家分月排行榜第一2007年5月 VC/MFC大版内专家分月排行榜第一2007年4月 VC/MFC大版内专家分月排行榜第一2007年3月 VC/MFC大版内专家分月排行榜第一
2013年3月 VC/MFC大版内专家分月排行榜第二2013年2月 VC/MFC大版内专家分月排行榜第二2008年8月 VC/MFC大版内专家分月排行榜第二2008年7月 VC/MFC大版内专家分月排行榜第二2007年9月 VC/MFC大版内专家分月排行榜第二2007年8月 VC/MFC大版内专家分月排行榜第二2005年12月 VC/MFC大版内专家分月排行榜第二2005年10月 VC/MFC大版内专家分月排行榜第二
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。

我要回帖

更多关于 大神f2 的文章

 

随机推荐