我正从plist中提取一些字符串数据:
<dict>
<key>Feb 7, 2000</key>
<array>
<string>7</string>
<string>8</string>
</array>
<key>Jan 27, 2001</key>
<array>
<string>8</string>
<string>7</string>
</array>
Run Code Online (Sandbox Code Playgroud)
并使用以下代码输出UILabel中的数据:
NSString * myString = [NSString stringWithFormat:@"%@",self.data];
myLabel.text = myString;
Run Code Online (Sandbox Code Playgroud)
输出显示为 ( 7, 8)
有没有人知道如何删除括号和逗号.并分离值,以便我可以显示类似的东西first: 7 second: 8
我有一个rootViewController,并有一个以编程方式创建的UIButton.我希望这个UIButton显示另一个视图控制器.由于某种原因,它崩溃与以下错误:
对于i386硬件架构未定义的符号:
未找到符号(S)为i386硬件架构collect2: "_OBJC_CLASS _ $ _ TutorialViewController",从引用:objc级,裁判在RootViewController.o LD LD返回1个退出状态
这是创建Info UIButton的代码.这段代码在loadView方法中:
// Create a Button to get Help
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ;
CGRect buttonRect = helpButton.frame;
// CALCulate the bottom right corner
buttonRect.origin.x = self.view.frame.size.width - buttonRect.size.width - 8;
buttonRect.origin.y = buttonRect.size.height - 8;
[helpButton setFrame:buttonRect];
[helpButton addTarget:self action:@selector(doHelp:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:helpButton];
}
Run Code Online (Sandbox Code Playgroud)
这是转换到另一个视图控制器的操作:
- (IBAction)doHelp:(id)sender{
NSLog(@"help button pressed");
TutorialViewController *sampleView = [[[TutorialViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:sampleView animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我试图将以下代码从if语句更改为switch语句,但我得到一个错误,说我需要一个整数而不是id对象.
这是我的开关:
-(void) nearestIndexAfterRotationEnded:(int)index {
NSLog(@"Selected item is: %@", [colorNames objectAtIndex:index]);
statusLabel.text = [NSString stringWithFormat:@"Selected item is: %@", [colorNames objectAtIndex:index]];
switch ([colorNames objectAtIndex:])) {
case 1:
[redButton setImage:[UIImage imageNamed:@"Btn1_1.png"] forState:UIControlStateNormal];
break;
case 2:
[redButton setImage:[UIImage imageNamed:@"Btn1_2.png"] forState:UIControlStateNormal];
break;
default:
break;
}
Run Code Online (Sandbox Code Playgroud)
这是我的if条件声明:
-(void) nearestIndexAfterRotationEnded:(int)index {
NSLog(@"Selected item is: %@", [colorNames objectAtIndex:index]);
statusLabel.text = [NSString stringWithFormat:@"Selected item is: %@", [colorNames objectAtIndex:index]];
if ([colorNames objectAtIndex:0]) {
[redButton setImage:[UIImage imageNamed:@"Btn1_1.png"] forState:UIControlStateNormal];
}
if ([colorNames objectAtIndex:1]) {
[redButton setImage:[UIImage imageNamed:@"Btn1_2.png"] forState:UIControlStateNormal];
}
if ([colorNames …Run Code Online (Sandbox Code Playgroud) 我遇到过这个错误:
No visible @interface for 'NSString' declares the selector 'JSONValue'.
Run Code Online (Sandbox Code Playgroud)
错误发生在:
NSDictionary * root = [responseString JSONValue];
NSArray *data = [root objectForKey:@"data"];
有谁知道如何修理它?我可以错过JSON文件吗?

在关闭另一个视图控制器上的页面卷曲后,如何重新加载视图控制器的表视图.
我在viewController1上有一个tableview,其中有一个使用页面curl到viewController2的转换.
viewController1有一个tableView,需要在页面curl关闭后重新加载.
谢谢你的帮助
我试图找出如何在应用程序内本地访问json文件.目前我一直在从这样的服务器远程使用json文件:
jsonStringCategory = @"http://****categories?country=us";
}
// Download the JSON file
NSString *jsonString = [NSString
stringWithContentsOfURL:[NSURL URLWithString:jsonStringCategory]
encoding:NSStringEncodingConversionAllowLossy|NSUTF8StringEncoding
error:nil];
NSLog(@"jsonStringCategory is %@", jsonStringCategory);
NSMutableArray *itemsTMP = [[NSMutableArray alloc] init];
// Create parser
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *results = [parser objectWithString:jsonString error:nil];
itemsTMP = [results objectForKey:@"results"];
self.arForTable = [itemsTMP copy];
[self.tableView reloadData];
Run Code Online (Sandbox Code Playgroud)
我试过这个:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"categoriesus" ofType:@"json"];
jsonStringCategory = [[NSString alloc] initWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在寻找使用 matplotlib 将烛台的灯芯部分变成黑色?我在文档中找不到任何提及它的内容,但我已经看到图片示例表明它可以完成。
这是我目前拥有的:
这是灯芯被涂成黑色的示例:
更新:
我使用了下面提供的解决方案,但稍微更改了代码以删除烛台主体区域上的垂直线:
from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle
def blackwickcandlestick(ax, quotes, width=0.2, colorup='#00FF00', colordown='#FF0000',
alpha=1.0, shadowCol='k', ochl=True):
OFFSET = width / 2.0
lines = []
patches = []
for q in quotes:
if ochl:
t, open, close, high, low = q[:5]
else:
t, open, high, low, close = q[:5]
if close >= open:
color = colorup
lower = open
height = close - open
vline = Line2D(
xdata=(t, t), ydata=(low, high),
color=colorup, # …Run Code Online (Sandbox Code Playgroud) 我想倾听/检测一个didSelectRowAtIndexPath:变化viewController1,然后根据这个选择改变一些东西viewController2.
知道我怎么可能这样做吗?
NSString要NSDate转换的回报null.
原始字符串输出" 2013-07-16T18:42:56 + 02:00 ",但当我尝试转换为NSDate它时返回"null"
这是我的代码:
// original string
NSString *str = [timeStamp objectAtIndex:indexPath.row];
// convert to date
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//[dateFormat setDateFormat:@"YYYY-MM-dd'T'HH:mm:ss'+11:00'"];
[dateFormat setDateFormat:@"YYYY-MM-dd'T'HH:mm:ssZZZ"]; // updated from Stavash's post below. Still null is outputted for the date though
[dateFormat setTimeZone:[NSTimeZone timeZoneWithName:@"Australia/Melbourne"]];
NSDate *dte = [dateFormat dateFromString:str];
cell.timeStampLabel.text = [NSString stringWithFormat:@"%@",dte ];
Run Code Online (Sandbox Code Playgroud) 我下载了一个JQuery UI模板并将其上传到服务器.它在本地工作,但不在服务器上.
有谁知道我错过了什么?
谢谢
ios ×8
objective-c ×8
iphone ×6
json ×2
nsstring ×2
charts ×1
jquery ×1
jquery-ui ×1
matplotlib ×1
nsdate ×1
page-curl ×1
python ×1
sbjson ×1
uitableview ×1