大家ios区哪个开的最早

主题 : 其中一个view不显示控件,什么原因?
级别: 新手上路
可可豆: 36 CB
威望: 48 点
在线时间: 8(时)
发自: Web Page
来源于&&分类
其中一个view不显示控件,什么原因?&&&
运行时其中一个view的控件不显示了。本来我是想黄色区域显示出来一些控件的&&
@interface oneViewController ()
@implementation oneViewController
&&&&self=[super init];
&&&&if (self) {
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
&&&&self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
&&&&if (self) {
-(void)loadView
&&&&UIView *view=[[UIView alloc]initWithFrame:[[UIScreen mainScreen]applicationFrame]];
&&&&view.backgroundColor=[UIColor clearColor];
&&&&self.view=//赋值;
&&&&[view release];
&&&&//add subView
&&&&UIView *twoview2=[[UIView alloc]initWithFrame:CGRectMake(0, 20, 320, 420)];
&&&&twoview2.backgroundColor=[UIColor yellowColor];
&&&&[view addSubview:twoview2];
&&&&[twoview2 release];
-(void)buuildLableFrame:(CGRect)frame string:(NSString *)textString superView:(UIView *)twoview2
&&&&//初始化Lable值
&&&&UILabel *label = [[UILabel alloc] initWithFrame:frame];
&&&&label.backgroundColor = [UIColor redColor];&&&&
&&&&label.textColor = [UIColor&&blackColor];
&&&&label.textAlignment = NSTextAlignmentC
&&&&label.text = textS
&&&&[twoview2 addSubview:label];
&&&&[label release];
//构建一个TextField
-(void)buildWithTextFieldFrame:(CGRect)frame string:(NSString *)string superView:(UIView *)twoview2 tag:(NSInteger)tag
&&&&UITextField * textField = [[UITextField alloc] initWithFrame:frame];
&&&&textField.borderStyle = UITextBorderStyleRoundedR
&&&&//比较两个值
&&&&if ([[textArray objectAtIndex:tag-array.count-1] isEqualToString:@&0&]) {
&&&&&&&&textField.placeholder =
&&&&}else{
&&&&&&&&textField.text = [textArray objectAtIndex:tag-array.count-1];
&&&&//初始化TextField的值
&&&&textField.tag =
&&&&textField.delegate =
&&&&textField.keyboardType = UIKeyboardTypeDecimalP
&&&&[twoview2 addSubview:textField];
&&&&[textField release];
//构建一个View
-(void)buildWithViewFrame:(CGRect)frame tag:(NSInteger)tag string:(NSString *)string superView:(UIView *)twoview2
&&&&//初始化View值
&&&&UIView * articView = [[UIView alloc] initWithFrame:frame];
&&&&articView.backgroundColor = [UIColor redColor];
&&&&articView.tag =
&&&&[twoview2 addSubview:articView];
&&&&//设置Lable的位置
&&&&[self buuildLableFrame:CGRectMake(0, 10, 100, 30) string:string superView:articView];
&&&&//设置TextField的位置
&&&&[self buildWithTextFieldFrame:CGRectMake(90, 10, 190, 30) string:string superView:articView tag:tag+array.count];
&&&&//为view添加手势
&&&&UIPanGestureRecognizer * swipe = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
&&&&swipe.delegate=
&&&&[articView addGestureRecognizer:swipe];
&&&&[swipe release];
&&&&[articView release];
-(void)build
&&&&[UIView beginAnimations:nil context:nil];
&&&&[UIView setAnimationDuration:0.3];
&&&&for (int i=0; i&array. i++) {
&&&&&&&&[self buildWithViewFrame:CGRectMake(0, 10+40*i, 320, 40) tag:i+1 string:[array objectAtIndex:i] superView:scrollView];
&&&&[[self.view viewWithTag:666] setFrame:CGRectMake(0, 10+40*array.count+10, 320, 256)];
&&&&scrollView.contentSize = CGSizeMake(320, 10+40*array.count+10+400);
&&&&[UIView commitAnimations];
- (void)viewDidLoad
&&&&[super viewDidLoad];
&&&&// Do any additional setup after loading the view, typically from a nib.
&&&&scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, heigh)];
&&&&scrollView.backgroundColor = self.view.backgroundC
&&&&UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
&&&&[scrollView addGestureRecognizer:tap];
&&&&[tap release];
&&&&array = [[NSMutableArray alloc] initWithObjects:@&早餐&,@&中餐&,@&晚餐&,@&零食&,@&水果&,nil];
&&&&textArray = [[NSMutableArray alloc] initWithObjects:@&0&,@&0&,@&0&,@&0&,@&0&,nil];
&&&&[self build];
&&&&UIView *twoview=[[UIView alloc]initWithFrame:CGRectMake(0,440, 320, 60)];
&&&&twoview.backgroundColor=[UIColor redColor];
&&&&[self.view addSubview:twoview];
&&&&[twoview release];
&&&&//设置工具栏
&&&&//创建一个保存按钮
&&&&UIButton * saveButton = [[UIButton alloc] init];
&&&&[saveButton setFrame:CGRectMake(255, 0, 60, 30)];
&&&&[saveButton setBackgroundColor:[UIColor clearColor]];
&&&&[saveButton setTintColor:[UIColor clearColor]];
&&&&[saveButton setTitle:@&保存& forState:UIControlStateNormal];
&&&&saveButton.titleLabel.font = [UIFont fontWithName:@&Arial Rounded MT Bold& size:30];
&&&&[saveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
&&&&[saveButton addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
&&&&[twoview addSubview:saveButton];
&&&&//创建一个添加按钮
&&&&UIButton * addButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
&&&&[addButton setFrame:CGRectMake(15, 0, 30, 30)];
&&&&[addButton setBackgroundColor:[UIColor clearColor]];
&&&&[addButton setTintColor:[UIColor clearColor]];
&&&&[addButton setBackgroundImage:[UIImage imageNamed:@&add.png&] forState:UIControlStateNormal];
&&&&[addButton setBackgroundImage:[UIImage imageNamed:@&add.png&] forState:UIControlStateHighlighted];
&&&&[addButton addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside];
&&&&[twoview addSubview:addButton];
&&&&//创建一个查看按钮
&&&&UIButton * allButton = [[UIButton alloc] init];
&&&&[allButton setFrame:CGRectMake(130, 0, 60, 30)];
&&&&[allButton setBackgroundColor:[UIColor clearColor]];
&&&&[allButton setTintColor:[UIColor clearColor]];
&&&&[allButton setTitle:@&查看& forState:UIControlStateNormal];
&&&&allButton.titleLabel.font = [UIFont fontWithName:@&Arial Rounded MT Bold& size:30];
&&&&[allButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
&&&&[allButton addTarget:self action:@selector(look) forControlEvents:UIControlEventTouchUpInside];
&&&&[twoview addSubview:allButton];
&&&&[saveButton release];
&&&&[allButton release];
#pragma mark - 取消键盘
-(void)tap:(UITapGestureRecognizer *)sender
&&&&for (int i=0; i&array. i++) {
&&&&&&&&[((UITextField *)[self.view viewWithTag:array.count+i+1]) resignFirstResponder];
#pragma mark - 拖动删除
-(void)swipe:(UIPanGestureRecognizer *)swipe
&&&&if (swipe.state == UIGestureRecognizerStateEnded) {
&&&&&&&&CGPoint point = [swipe locationInView:scrollView];
&&&&&&&&if (abs(point.x - startPoint.x)&100 && abs(point.y - startPoint.y)&20) {
&&&&&&&&&&&&int num = swipe.view.
&&&&&&&&&&&&for (int i=0; i&array. i++) {
&&&&&&&&&&&&&&&&[[self.view viewWithTag:i+1] removeFromSuperview];
&&&&&&&&&&&&}
&&&&&&&&&&&&[array removeObjectAtIndex:num-1];
&&&&&&&&&&&&[textArray removeObjectAtIndex:num-1];
&&&&&&&&&&&&[self build];
#pragma mark - 保存
-(void)save
&&&&UIAlertView * alerView = [[UIAlertView alloc] initWithTitle:@&提示& message:@&确定保存?& delegate:self cancelButtonTitle:@&取消& otherButtonTitles:@&确定&, nil];
&&&&alerView.tag = 888;
&&&&[alerView show];
&&&&[alerView release];
&&&&[self textWhetherNill];
#pragma mark - 添加
-(void)add
&&&&UIAlertView * alerView = [[UIAlertView alloc] initWithTitle:@&提示& message:@&确定添加?& delegate:self cancelButtonTitle:@&取消& otherButtonTitles:@&确定&, nil];
&&&&alerView.tag = 889;
&&&&UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(0,50, 120, 30)];
&&&&textField.placeholder = @&请输入名称&;
&&&&textField.textAlignment = NSTextAlignmentL
&&&&textField.contentVerticalAlignment = UIControlContentVerticalAlignmentC
&&&&textField.font = [UIFont systemFontOfSize:20];
&&&&[alerView addSubview:textField];
&&&&textField.backgroundColor = self.view.backgroundC
&&&&[textField release];
&&&&[alerView show];
&&&&[alerView release];
#pragma mark - 查看
//-(void)look
//&&&&LookViewController * lookVC = [[LookViewController alloc] initWithNibName:@&LookViewController& bundle:nil];
//&&&&UINavigationController * navigationVC = [[UINavigationController alloc] initWithRootViewController:lookVC];
//&&&&[self presentViewController:navigationVC animated:YES completion:nil];
//&&&&[lookVC release];
//&&&&[navigationVC release];
#pragma mark - UITextField delegate
- (void)textFieldDidEndEditing:(UITextField *)textField
&&&&[textArray replaceObjectAtIndex:textField.tag-array.count-1 withObject:textField.text];
#pragma mark - UIAlertView delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
&&&&if (buttonIndex == 1) {
&&&&&&&&if (alertView.tag == 888) {
&&&&&&&&&&&&//创建文件管理器
&&&&&&&&&&&&NSFileManager *fileManager = [NSFileManager defaultManager];
&&&&&&&&&&&&//获取路径
&&&&&&&&&&&&//参数NSDocumentDirectory要获取那种路径
&&&&&&&&&&&&NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
&&&&&&&&&&&&NSString *documentsDirectory = [paths objectAtIndex:0];//去处需要的路径
&&&&&&&&&&&&//更改到待操作的目录下
&&&&&&&&&&&&[fileManager changeCurrentDirectoryPath:[documentsDirectory stringByExpandingTildeInPath]];
&&&&&&&&&&&&//创建文件fileName文件名称,contents文件的内容,如果开始没有内容可以设置为nil,attributes文件的属性,初始为nil
&&&&&&&&&&&&//获取文件路径
&&&&&&&&&&&&//&&&&[fileManager removeItemAtPath:@&username&error:nil];
&&&&&&&&&&&&NSString * path = [documentsDirectory stringByAppendingPathComponent:@&cc.txt&];
&&&&&&&&&&&&
&&&&&&&&&&&&NSMutableData *writer1 = [[NSMutableData alloc] init];
&&&&&&&&&&&&NSString * st = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
&&&&&&&&&&&&
&&&&&&&&&&&&NSDate *select = [dataPick date];
&&&&&&&&&&&&NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
&&&&&&&&&&&&[dateFormatter setDateFormat:@&yyyy-MM-dd&];
&&&&&&&&&&&&NSString *dateAndTime =&&[dateFormatter stringFromDate:select];
&&&&&&&&&&&&[dateFormatter release];
&&&&&&&&&&&&NSString * string = [[[NSMutableString alloc] init] autorelease];
&&&&&&&&&&&&if (st == nil) {
&&&&&&&&&&&&&&&&for (int i=0; i&array. i++) {
&&&&&&&&&&&&&&&&&&&&string = [string stringByAppendingFormat:@&%@:%@&&&&&,[array objectAtIndex:i],((UITextField *)[self.view viewWithTag:array.count+i+1]).text];
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}else{
&&&&&&&&&&&&&&&&string = [string stringByAppendingFormat:@&%@\n&,st];
&&&&&&&&&&&&&&&&for (int i=0; i&array. i++) {
&&&&&&&&&&&&&&&&&&&&string = [string stringByAppendingFormat:@&%@:%@&&&&&,[array objectAtIndex:i],((UITextField *)[self.view viewWithTag:array.count+i+1]).text];
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&&&&&string = [string stringByAppendingFormat:@&日期:%@&,dateAndTime];
&&&&&&&&&&&&//将字符串添加到缓冲中
&&&&&&&&&&&&[writer1 appendData:[string dataUsingEncoding:NSUTF8StringEncoding]];
&&&&&&&&&&&&//将其他数据添加到缓冲中
&&&&&&&&&&&&//将缓冲的数据写入到文件中
&&&&&&&&&&&&BOOL yesOrNo = [writer1 writeToFile:path atomically:YES];
&&&&&&&&&&&&[writer1 release];
&&&&&&&&&&&&
&&&&&&&&&&&&if (yesOrNo) {
&&&&&&&&&&&&&&&&UIAlertView * alerView = [[UIAlertView alloc] initWithTitle:@&提示& message:@&保存成功& delegate:nil cancelButtonTitle:@&确定& otherButtonTitles: nil];
&&&&&&&&&&&&&&&&[alerView show];
&&&&&&&&&&&&&&&&[alerView release];
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&for (int i=0; i&array. i++) {
&&&&&&&&&&&&&&&&&&&&((UITextField *)[self.view viewWithTag:array.count+i+1]).text =
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&}else{
&&&&&&&&&&&&for (id view in alertView.subviews) {
&&&&&&&&&&&&&&&&if ([view isKindOfClass:[UITextField class]]) {
&&&&&&&&&&&&&&&&&&&&if (((UITextField *)view).text != nil) {
&&&&&&&&&&&&&&&&&&&&&&&&for (int i=0; i&array. i++) {
&&&&&&&&&&&&&&&&&&&&&&&&&&&&[[self.view viewWithTag:i+1] removeFromSuperview];
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&[array addObject:((UITextField *)view).text];
&&&&&&&&&&&&&&&&&&&&&&&&[textArray addObject:@&0&];
&&&&&&&&&&&&&&&&&&&&&&&&[self build];
&&&&&&&&&&&&&&&&&&&&}else{
&&&&&&&&&&&&&&&&&&&&&&&&UIAlertView * alerView = [[UIAlertView alloc] initWithTitle:@&提示& message:@&不能为空& delegate:nil cancelButtonTitle:@&确定& otherButtonTitles:nil];
&&&&&&&&&&&&&&&&&&&&&&&&[alerView show];
&&&&&&&&&&&&&&&&&&&&&&&&[alerView release];
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
#pragma mark - 没有输入为0
-(void)textWhetherNill
&&&&for (int i=0; i&array. i++) {
&&&&&&&&if (((UITextField *)[self.view viewWithTag:array.count+i+1]).text == nil) {
&&&&&&&&&&&&((UITextField *)[self.view viewWithTag:array.count+i+1]).text = @&其他&;
#pragma mark - UIGestureRecognizerDelegate delegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
&&&&startPoint = [gestureRecognizer locationInView:scrollView];
&&&&return YES;
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
&&&&return YES;
- (void)dealloc
&&&&dataPick =
&&&&[array release],array =
&&&&scrollView =
&&&&[textArray release],textArray =
&&&&[super dealloc];
-(void)viewWillAppear:(BOOL)animated
&&&&[super viewWillAppear:animated];
-(void)viewWillDisappear:(BOOL)animated
&&&&[super viewWillDisappear:animated];
- (void)didReceiveMemoryWarning
&&&&[super didReceiveMemoryWarning];
&&&&// Dispose of any resources that can be recreated.
级别: 新手上路
可可豆: 36 CB
威望: 48 点
在线时间: 8(时)
发自: Web Page
会不会是被其他挡住的原因呢?&& 坐等求解!!
级别: 新手上路
可可豆: 66 CB
威望: 16 点
在线时间: 75(时)
发自: Web Page
去掉黄色 一看就知道是不是了。。。。
级别: 骑士
可可豆: 811 CB
威望: 731 点
在线时间: 78(时)
发自: Web Page
po [self.view recursiveDescription]
ivanchan.github.io
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版我的自定义控件在界面上显示不出来
这是为什么
这是我自定义的一个控件由两个按钮 和一个editText组成
可是为什么我的控件不能显示出来呢  这是我的Java代码实现一些属性的设置public class MyTopbar extends RelativeLayout{
private String title,leftbutton,
private Button leftBtn,rightB
private EditText
private LayoutParams paramRight,paramsLeft,paramsT
public MyTopbar(Context context, AttributeSet attrs) {super(context, attrs);
TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.MyTopbar);
title = ta.getString(R.styleable.MyTopbar_title);
leftbutton = ta.getString(R.styleable.MyTopbar_leftbutton);
rightbutton = ta.getString(R.styleable.MyTopbar_rightbutton);
ta.recycle();
leftBtn = new Button(context);
rightBtn = new Button(context);
editText = new EditText(context);
leftBtn.setText(leftbutton);
rightBtn.setText(rightbutton);
editText.setText(title);
paramsLeft = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_LEFT,TRUE);
addView(leftBtn, paramsLeft);
paramRight = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
paramRight.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,TRUE);
addView(rightBtn, paramRight);
paramsTitle = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
paramsTitle.addRule(RelativeLayout.CENTER_IN_PARENT,TRUE);
addView(editText,paramsTitle);
}}  接下来是我的xml 文件 自定义了属性  &resources&
&declare-styleable name="MyTopbar"&
&attr name="title" format="string" /&
&attr name="leftbutton" format="string" /&
&attr name="rightbutton" format="string" /&
&/declare-styleable&&/resources&  然后是引用我自定义的控件  &com.example.administrator.topbar.MyTopbar
android:layout_width="match_parent"
android:layout_height="104dp"
android:paddingLeft="20dp"
android:paddingBottom="40dp"
android:background="#b4ff66"
app:rightbutton="按钮右"
app:leftbutton="按钮左"
app:title="这是我的第一个自定义控件"
android:layout_gravity="center"&&/com.example.administrator.topbar.MyTopbar& 
写下你的评论...
写下你的评论...
Copyright (C)
All Rights Reserved | 京ICP备 号-2> 多个SurfaceView的布局问题(同一布局内的其它的控件无法显示)
多个SurfaceView的布局问题(同一布局内的其它的控件无法显示)
nkd2002 & &
发布时间: & &
浏览:2 & &
回复:1 & &
悬赏:0.0希赛币
我的本意是在线性布局下放三个控件:两个SurfaceView和一个Button,我的每个控件都设置了android:layout_weight这一属性,按照比例应该是4:4:1显示的,可是最终显示的时候,Button却没显示出来。其实我发现的SurfaceView类似的现象还有很多,先搞清楚这一个。请问这是什么原因?显示效果如下图:这里是我的布局文件main.xml&?xml&version="1.0"&encoding="utf-8"?&&LinearLayout&xmlns:android="/apk/res/android"&&&&android:layout_width="match_parent"&&&&android:layout_height="match_parent"&&&&android:orientation="vertical"&&&&&&&&& &SurfaceView&&&& &&&&&&&android:layout_width="match_parent"&android:layout_height="wrap_content"&&&&& &&&&&&&android:background="@drawable/boud"&&android:id="@+id/sf13"&&&&& &&&&&&&&android:layout_weight="4"&&&&& &&&&&&&&&!--&drawable/boud"是我自定义的背景文件,作用是显示SurfaceView的边界&--&&&&& &&/SurfaceView&&&&& &&SurfaceView&&&& &&&&&&&android:layout_width="match_parent"&android:layout_height="wrap_content"&&&&& &&&&&&&android:background="@drawable/boud"&&android:id="@+id/sf15"&&&&& &&&&&&&android:layout_weight="4"&&&&& &&/SurfaceView&&&& &Button&android:layout_width="match_parent"&android:layout_height="wrap_content"&&android:id="@+id/bt22"&&& &&&&&android:layout_weight="1"/&&/LinearLayout&
把button设置text,然后把layout_weight去掉mht3anara & &
17:37:59 & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经解决,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&2861人阅读
XCode(17)
问题描述:
有如下3个UIViewController
StartViewController:除了一个View外什么也没有
LoadViewController:一个View和一个Socket
GameViewController:一个View,View里的button,View里的ImageView,一个Socket
逻辑流程如下:
第一步:在StartViewController.m中先加载LoadView
loadViewController = [[LoadViewController
alloc] initWithNibName:[AppDelegate
currentDelegate].loadNibFileName
bundle:nil];
[self.view
addSubview:loadViewController.view];
第二步:LoadView是关于Socket通讯,在处理Socket通讯的时候用到如下函数:(没有启动额外的线程,依然是主线程)
-(void)statusProcess:(uint8_t)statusCode {
& & switch (statusCode) {
& & & & ........
& & & & case SOCKET_RCVING:& {
& & & & & & S32 result = ........;
& & & & & & switch (result) {
& & & & & & & & case
& & & & & & & & & &//发送消息,初始化GameViewController
& & & & & & & & & & [[AppDelegate
currentDelegate].startViewController
performSelector:@selector(initGameViewController)];
& & & & & & & & & & break;
& & & & & & & & }
& & & & & & & & case
& & & & & & & & & & ....
& & & & & & & & }
& & & & & & }
& & & & & & break;
& & & &......
& & & & default:
& & & & & & break;
第三步:初始化GameViewController
-(void)initGameViewController {
& & gameViewController = [[GameViewController
alloc] initWithNibName:[AppDelegate
currentDelegate].gameNibFileName
bundle:nil];
& & [gameViewController createServer];
第四步:创建gameViewController的Socket和执行Socket,依然是statusProcess函数
-(void)statusProcess:(uint8_t)statusCode {
& & switch(statusCode) {
& & & &.....
& & & & case
SOCKET_SENDING: {
& & & & & & //启动解析线程
& & & & & & [NSThread detachNewThreadSelector:@selector(dataAnalysisThread)
toTarget:self withObject:nil];
& & & & & & break;
& & & & .....
& & & & default:
& & & & & & break;
第五步:启动解析线程dataAnalysisThread
-(void)dataAnalysisThread {
& & float coreAnalysisTimer =
& & & & int flag = ...........;
& & & & switch (flag) {
& & & & & & .....
& & & & & & case
& & & & & & & & [appDelegate.startViewController
performSelectorOnMainThread:@selector(changeViewFromLoadViewToGameView)
withObject:nil waitUntilDone:YES];
& & & & & & & & break;
& & & & & & }
& & & & & &case xxx2: {
& & & & & & & & //往ImageView里添加内容
& & & & & & & &
& & & & & &}
& & & & & &.....
& & & & & & default: {
& & & & & & & & //NSLog(@&获得其他tag
:%d&,flag);
& & & & & & & & break;
& & & & & & }
& & }while(xxxxxx); &&
第六步:显示GameViewController
-(void)changeViewFromLoadViewToGameView {
removeLoadView];
& & [self.view addSubview:gameViewController.view];
此时就会出现GameViewController的button居然显示不了,ImageView可以正常显示
解决的办法是如下:
把第三步的函数更改成如下:
-(void)initGameViewController {
& & gameViewController = [[GameViewController
alloc] initWithNibName:[AppDelegate
currentDelegate].gameNibFileName
bundle:nil];
& & [gameViewController createServer];
& & //这里非常的重要,解决button不显示的问题
& & [self.view
insertSubview:gameViewController.view
atIndex:1];
把第六步的函数更改成如下:
-(void)changeViewFromLoadViewToGameView {
& & //这里非常的重要,解决button不显示的问题
removeLoadView];
& & //[self.view addSubview:gameViewController.view];
这样就可以正常的显示button和ImageView了
在initGameViewController的时候,就把View加入到self.view中,但是被loadView给遮住了,
在changeViewFromLoadViewToGameView的时候,把loadView给remove掉
花了6,7个多小时才解决这个问题。
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:370070次
积分:6974
积分:6974
排名:第2944名
原创:358篇
转载:75篇
评论:33条
(10)(1)(1)(2)(4)(2)(4)(8)(9)(4)(4)(3)(3)(1)(5)(4)(4)(4)(3)(2)(16)(7)(1)(3)(8)(1)(5)(4)(2)(1)(4)(1)(2)(2)(1)(7)(6)(49)(69)(32)(16)(13)(16)(46)(39)(5)}

我要回帖

更多关于 ios开发社区 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信