在我的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) 例如,我有一个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)
但显示损坏的字符
-(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)
但它崩溃在上面的线:
我正在开发一个股票软件,客户端将从服务器接收数据,所以我想使用CFNetwork.我在哪里可以找到"网络入门"教程,谢谢
我有一个char数组,char契约[8];并将值赋给数组,我想打印该值,所以我使用NSLog(@"%@",contract);
并构建成功.但运行不正确.
我有一个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
?
我有一个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)
我可以找到每个方法的断点 …