我从CoreData fetch中创建了一个NSArray,如下所示:
self.farSiman = [self.managedObjectContext executeFetchRequest:request error:&error];
Run Code Online (Sandbox Code Playgroud)
在tableview中,我使用此代码来获取自定义对象:
Holiday *holiday = [self.dates objectAtIndex:indexPath.row];
cell.nameLabel.text = holiday.name;
Run Code Online (Sandbox Code Playgroud)
但是我现在在另一个viewcontroller中,试图在mapkit上绘制数据,所以在绘图方法中我最初这样做是因为我从plist文件中获取了一个数组.但现在我的数组是自定义Holiday对象,所以这不再起作用了:
NSLog(@"dictionary is %@", self.farSiman);
for (NSDictionary * dict in self.farSiman) {
NSNumber * latitude = [dict objectForKey:@"latitude"];
NSNumber * longitude = [dict objectForKey:@"longitude"];
NSString * storeDescription = [dict objectForKey:@"name"];
NSString * address = [dict objectForKey:@"address"];
NSLog(@"logging location %@", storeDescription);
CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude.doubleValue;
coordinate.longitude = longitude.doubleValue;
MyLocation *annotation = [[MyLocation alloc] initWithName:storeDescription address:address coordinate:coordinate];
[_mapView addAnnotation:annotation];
}
Run Code Online (Sandbox Code Playgroud)
我的字典日志打印出来:
dictionary is (
"<Holiday: …Run Code Online (Sandbox Code Playgroud) 我设法创建Array的MyLocation与在第2个选项卡设置的距离属性的对象tabBarController.在我的第二个标签中,我得到它viewDidLoad:
[self setAnnotationsToSort:myDelegate.annotationsToSort];
Run Code Online (Sandbox Code Playgroud)
在这一行之后我称这种方法:
-(void)sort{
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"distance" ascending:YES] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [self.annotationsToSort sortedArrayUsingDescriptors:sortDescriptors];
[self.tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
这应该排序我的Array.但是我tableView目前加载了未分类的版本Array,self.annotationsToSort.我如何重新加载tableView但强制它使用新的sortedArray?
我有这个字符串返回:
"周一至周五上午8:00 - 下午7:30"
为了得到这个,我需要消除mon-fri的东西:
"上午8:00 - 晚上7:30"
然后我需要将其拆分为开放时间和关闭时间,以确定它是否开放:
"上午8:00"&&"晚上7:30"
但是有很多商店,他们有不同的开放和关闭时间,所以我不能从8提取6个字符或类似的东西.
到目前为止,我决定走这条路:
NSRange startRange = [storeTime.text rangeOfString:@"-"];
NSString *openString = [storeTime.text substringWithRange:NSMakeRange(16, startRange.location-17)];
NSString *closeString = [storeTime.text substringWithRange:NSMakeRange(startRange.location+2, storeTime.text.length-(startRange.location+2))];
Run Code Online (Sandbox Code Playgroud)
但似乎我可能会因为16岁的硬编码而破裂,这让我想知道它是否会在其他地方破坏.有关如何实现这一目标的更好的想法?
如何创建像Facebook消息一样的循环UIView.
它只是一个圆角的矩形还是一个中心有圆形图像的矩形?
这是图像视图:
这是自定义单元类的initWithStyle代码:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.userImage setBackgroundColor:[UIColor orangeColor]];
[self.userImage.layer setCornerRadius:32.0f];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到一个矩形的图像视图.
我试图在macOS Sierra上安装Odoo v9.我把它安装在virtualenv下,但是当我运行它(odoo.py)时,我得到一个无法执行命令lessc.我找到了这个:
https://dedyyuristiawan.blogspot.com/2016/07/installation-odoo-on-mac-os-x-error.html
但是当我尝试运行sudo brew时...我收到此错误:
Error : Running Homebrew as root is extremely dangerous and no longer supported.
Run Code Online (Sandbox Code Playgroud)
我在没有sudo的情况下运行它,但我得到:
Error: Permission denied - usr/local/lib/node_modules/npm/.github/issue_template.md
Run Code Online (Sandbox Code Playgroud)
当我跑啤酒医生时,我得到:
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or …Run Code Online (Sandbox Code Playgroud) 就在你认为自己明白了什么的时候,你却没有!:)
我知道如果我将变量设为属性,我可以在类中的任何位置访问它,甚至可以从该类外部设置它.
我想如果我不需要它我可以把它变成一个伊娃.所以我有一个大约5个UILabel的viewcontroller.所以在它的viewDidLoad我说:
pharmacyName.text = self.receivedLocation.name;
pharmacyTel1.text = @"556-7843";
pharmacyTel2.text = @"991-2345";
pharmacyTel3.text = @"800-0001";
Run Code Online (Sandbox Code Playgroud)
当我在.h文件中声明它们时:
@interface DetailViewController : UIViewController{
IBOutlet UILabel *pharmacyName;
IBOutlet UILabel *pharmacyTel1;
IBOutlet UILabel *pharmacyTel2;
IBOutlet UILabel *pharmacyTel3;
}
@property (nonatomic,strong) MyLocation *receivedLocation;
@end
Run Code Online (Sandbox Code Playgroud) 我在控制台中记录了这个日期字符串:
2013-8-11 10:00 PM
我运行这个dateFormatter,以使其成为一个NSDate:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"MST"]];
NSDate *openDate = [dateFormatter dateFromString:adjustedOpenDateString];
NSLog(@"DEALWITHTIMESTRINGS = open, now, close %@,%@,%@", openDate,[NSDate date], closeDate);
Run Code Online (Sandbox Code Playgroud)
但是当我记录它时,openDate会显示NULL.closeDate也是如此.
我在.m中有这个代码的UIViewController:
@property (nonatomic,strong) IBOutlet UINavigationBar *navBar;
@property (nonatomic,strong) IBOutlet UIBarButtonItem *button;
@end
@implementation DetailViewController
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIBarButtonItem *listoButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ListoBtn1.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(done:)];
self.navBar.topItem.rightBarButtonItem = listoButton;
//self.navBar.topItem.backBarButtonItem = self.button;
[self setVariables];
}
Run Code Online (Sandbox Code Playgroud)
按钮出现但看起来像这样:

我只是希望我的图像出现,而不是后退按钮.如何删除边框?
我有一个cellForRowAtIndexPath方法,它使用一个开关来构建像这样的单元格:
switch (indexPath.row) {
case 0:
cell.imageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
[cell.imageView setFrame:CGRectMake(5, 5, cell.imageView.image.size.width, cell.imageView.image.size.height)];
break;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我改成了这个:
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"] autorelease];
switch (indexPath.row) {
case 0:
self.locationButtonImageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
//cell.imageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
break;
Run Code Online (Sandbox Code Playgroud)
单元格加载时没有按钮图像.如果我点击单元格,则切换工作并显示所选按钮图像,然后继续切换.所以这可能是装载太晚的问题,对吧?
ios ×8
objective-c ×3
nsarray ×2
enumeration ×1
frame ×1
homebrew ×1
ivars ×1
nsstring ×1
odoo-9 ×1
properties ×1
substring ×1
uiimageview ×1
uitableview ×1
uiview ×1