小编Gao*_*188的帖子

self.navigationController为null

在我的viewcontroller中,我有一个按钮,按下按钮,输入navigationController,我的代码如下:

-(IBAction)ShangHaiButtonPressed:(id)sender{
    marketviewcontroller = [[MarketViewController alloc]initWithNibName:@"MarketViewController" bundle:nil];
    NSLog(@"%@",self.navigationController);
    [self.navigationController pushViewController:marketviewcontroller animated:YES];
    [marketviewcontroller release];   
}
Run Code Online (Sandbox Code Playgroud)

但我可以看到self.navigationController为null,如何解决这个问题?谢谢.

更新:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    _switchviewcontroller = [[SwitchViewController alloc]initWithNibName:@"SwitchViewController" bundle:nil];
    [self.window addSubview:_switchviewcontroller.view];
    [self.window makeKeyAndVisible];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

iphone navigationcontroller

11
推荐指数
1
解决办法
4万
查看次数

如何将char数组更改为NSString

例如,我有一个char数组:

char array[8];
Run Code Online (Sandbox Code Playgroud)

我试过了:

NSString *marketPacket = [NSString stringWithCString:array encoding:NSASCIIStringEncoding];
NSLog(@"%@",marketPacket);
Run Code Online (Sandbox Code Playgroud)

但显示损坏的字符

iphone nsstring

7
推荐指数
2
解决办法
1万
查看次数

[__NSCFDictionary setObject:forKey:]:将mutating方法发送到不可变对象

-(id)init{
    if (self==[super init]) {            
        NSMutableArray *listname = [[NSMutableArray alloc]initWithObjects:@"cu",@"al",@"zn",@"au",@"ru",@"fu",@"rb",@"pb",@"wr", nil];            
        NSMutableArray *listVolumn = [NSMutableArray arrayWithCapacity:[listname count]];           
        for (int i=0; i<[listname count]; i++) {
            [listVolumn addObject:[NSNumber numberWithLong:0]];
        }
        nsmutabledictionary = [[NSDictionary alloc] initWithObjects:listVolumn forKeys:listname];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

在我的init方法中,我定义了两个NSMutableArray,并添加到NSMutableDictionary nsmutabledictionary.在我的另一种方法:

[nsmutabledictionary setObject:[NSNumber numberWithLong:100] forKey:@"cu"];
Run Code Online (Sandbox Code Playgroud)

但它崩溃在上面的线: 在此输入图像描述

iphone

6
推荐指数
1
解决办法
1万
查看次数

我需要一些关于iphone中CFNetwork的教程

我正在开发一个股票软件,客户端将从服务器接收数据,所以我想使用CFNetwork.我在哪里可以找到"网络入门"教程,谢谢

iphone cfnetwork

4
推荐指数
1
解决办法
7991
查看次数

iphone,如何打印char数组

我有一个char数组,char契约[8];并将值赋给数组,我想打印该值,所以我使用NSLog(@"%@",contract);并构建成功.但运行不正确.

arrays iphone char

2
推荐指数
1
解决办法
4282
查看次数

(iphone)如何只更新tableview中的一行

我有一个tableview,我将tableview每隔一秒更新.it接收数据中的数据,当收到数据时,它将替换一行中的旧数据.我喜欢这样:当收到数据时,我打电话

[m_tableView reloadData];
Run Code Online (Sandbox Code Playgroud)

所以,它会打电话

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath{ }
Run Code Online (Sandbox Code Playgroud)

所以我将更改此方法中的特定行数据,但我该如何设置row index

uitableview ios

1
推荐指数
1
解决办法
5222
查看次数

tableview委托方法从未调用过

我有一个viewcontroller,并实现委托UITableViewDelegate和UITableViewDataSource,所以我有以下方法:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    return [_nameArray count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"name";
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
   static NSString *TableIdentifier = @"TableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableIdentifier]autorelease];
    }
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.textAlignment = UITextAlignmentLeft;    
    nameLabel.text = @"100";
    nameLabel.backgroundColor = [UIColor blackColor];
    nameLabel.textColor = [UIColor yellowColor];
    [cell.contentView addSubview:nameLabel];
    [nameLabel release];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

我可以找到每个方法的断点 …

iphone objective-c uitableview

0
推荐指数
2
解决办法
6373
查看次数