单例传值 南哥教的
来源:互联网 发布:手机数据上网慢怎么办 编辑:程序博客网 时间:2024/06/12 23:05
//pch文件里面写出宏 这是系统的单例类 当然也是可以自己去写一个单例类的
#define APPDELEGATE UIApplication * app = [UIApplication sharedApplication];AppDelegate * appdelegate = (AppDelegate *)app.delegate;
刚开始写在cellforRow函数里面 这个函数是进不来的 所有另外一个界面虽然打印是有值的 但是没传过来的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier =@"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// for (UIView *view in cell.subviews) {
// [view removeFromSuperview];
// }
//
if (cell == nil) {
cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.textLabel.text = [[dataArrayobjectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
if (indexPath.section==0) {
if (indexPath.row==1) {
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
lab00=[[UILabelalloc] initWithFrame:CGRectMake(200,0, 120, 48)];
lab00.backgroundColor=clear;
// lab.text=[arr objectAtIndex:indexPath.row-1];
// MySingletonClass *sing=[MySingletonClass mySharedApplication]; 自己写的单例类
// lab.text=sing.huiFui;
// lab.text=@"fdshjjkfds";
//
// APPDELEGATE; //这个是由宏定义得来的 系统的单例类
// lab00.text=appdelegate.chuanzhi;
// NSLog(@"%@",appdelegate.chuanzhi);、//此时这个函数里面打印出来是没有值的
lab00.textColor=Black1;
lab00.font=FONT_13;
lab00.textAlignment=NSTextAlignmentLeft;
[celladdSubview:lab00];
[lab00release];
}
此时应该 把lab00 写成是全局的 刚进入界面的时候 总会调用这几个函数的 viewwillappear 也是可以的
-(void)viewDidAppear:(BOOL)animated
{
APPDELEGATE;
if(appdelegate.chuanzhi !=nil){
lab00.text = appdelegate.chuanzhi; 相当于代理中的回调
}
}
//楠哥教的。。。。。。
- 单例传值 南哥教的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- 的
- Linux下sar 详解
- 日期DatePicker和时间TimePicker
- GDB调试应用
- Deep Learning论文笔记之(三)单层非监督学习网络分析
- 常用设计模式概览
- 单例传值 南哥教的
- JAVA文件操作基础
- vmware 虚拟机删除磁盘带来的问题
- ubuntu 12.04使用gedit打开txt文件中文乱码的处理方法
- ZFS文件系统(8) -- SLOG
- opengl绘制线
- 浏览器复制功能。
- &#x开头的是什么编码呢。浏览器可以解释它。如中国等同与中文"中国"?
- 树状数组,小结_(优雅的数据结构)