我有一个非常烦人的问题,我似乎无法修复.
我有一个视图,当我发送一条消息,保存到核心数据,当它完成时它向数据库询问随机消息(句子)并将其保存到数据库中的另一行.
如果我最后一部分硬编码,没有从数据库中获取数据,它可以正常工作,但是只要我从数据库中获取随机行就会发疯.
在我的AppDelegate.m中:
- (void)save {
NSAssert(self.context != nil, @"Not initialized");
NSError *error = nil;
BOOL failed = [self.context hasChanges] && ![self.context save:&error];
NSAssert1(!failed,@"Save failed %@",[error userInfo]);
}
- (NSString*)selectRandomSentence
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Sentences" inManagedObjectContext:self.managedObjectContext];
[request setEntity:entity];
NSError *error = nil;
NSUInteger count = [self.context countForFetchRequest:request error:&error];
NSUInteger offset = count - (arc4random() % count);
[request setFetchOffset:offset];
[request setFetchLimit:1];
NSArray *sentenceArray = [self.context executeFetchRequest:request error:&error];
[request release];
return [[sentenceArray objectAtIndex:0] sentence]; …Run Code Online (Sandbox Code Playgroud) core-data objective-c nsmanagedobject nsmanagedobjectcontext ios
我一直在努力完成这项任务已有一段时间了.我想要开发的是一个scrollview或collectionview,它可以连续滚动垂直和水平.
这是我认为这应该是什么样子的图像.透明框是从存储器重新加载的视图/单元.一旦视图/单元格进入屏幕之外,它就应该重新用于即将到来的新单元格......就像它的UITableViewController工作方式一样.

我知道一个UICollectionView只能做到无限滚动水平或垂直,而不是两者.但是,我不知道如何使用a UIScrollView.我尝试了关于这个问题的答案所附的代码,我可以让它重新创建视图(例如%20),但这不是我真正需要的东西..此外,它不是连续的.
我知道这是可能的,因为HBO Go应用程序这样做..我想要完全相同的功能.
我的问题:我怎样才能实现目标?是否有任何指南/教程可以告诉我如何?我找不到任何东西.
我有一个棘手的问题.在我的一个应用程序中,有超过150,000次下载...我遇到了一个很少发生的问题,我似乎无法弄明白.
问题如下:在用户可以通过电子邮件共享列表的视图中,我使用打开邮件窗口MFMailComposeViewController.但是,在少数情况下,应用程序似乎使用邮件编辑器出现问题.用户按下共享按钮,邮件窗口向上滑动,等待约1-2秒,然后再次关闭.邮件窗口中没有内容,尽管我确实向其发送数据.我自己无法在任何设备或模拟器中重新创建问题,但是有一位同事.我在他的手机上使用XCode运行应用程序并在日志中获得以下内容:
2013-03-01 14:43:39.604 appname[318:907] <MFMailComposeRemoteViewController: 0x1ebfb100> timed out waiting for fence barrier from com.apple.MailCompositionService
2013-03-01 14:43:39.631 appname[318:907] viewServiceDidTerminateWithError: Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)"
Run Code Online (Sandbox Code Playgroud)
我搜索了错误"从com.apple.MailCompositionService等待栅栏屏障超时",但无法找到任何帮助.
有没有人有这方面的经验?我该如何解决?
我打开视图的代码:
-(void)displayComposerSheetWithBodyString:(NSString *)aBody
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Lista"];
NSString *emailBody = aBody;
[picker setMessageBody:emailBody isHTML:NO];
[self.navigationController presentModalViewController:picker animated:YES];
}
else
{
[[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Din enhet är inte redo att skicka e-post. Kontrollera dina inställningar", nil)
message:nil
delegate:self …Run Code Online (Sandbox Code Playgroud) 我最近将我的5个独立项目合并到一个项目中,以拥有一个共同的代码库.所以现在我有一个项目有5个目标.
每个目标具有相同的文件集,但每个目标不同的某些文件除外(例如Default.png和其他图标文件).我的应用程序被翻译成7种语言,默认为英语.其他语言包括:瑞典语,荷兰语,德语,法语,波兰语和西班牙语.
现在我还想根据使用的语言翻译应用程序的名称.例如,对于我的瑞典航空应用程序,该应用程序应该在瑞典语中称为"Flyget ARN",但对于英语,它应该被称为"航空ARN".这一切都不是问题,因为这是在完成InfoPlist.string,但结合这与应用程序的本地化是一个问题.
我最近写了这个问题:几个本地化仍然只显示英语,并发现我无法组合几个.strings文件.(见我写的答案).
所以我的问题如下:
如何从包含多个目标的项目中获得本地化应用程序,并且本地化我的应用程序名称而不会出现DRY违规(重复代码).
更新
这仍然是一个问题,给出的答案并不能解决我的问题.
我有一个UIViewController叫RootViewController和A UIViewController叫NewsViewController.我想在NewsViewController里面展示一个UIView(这UIView只是屏幕的一部分)RootViewController.我正在使用StoryBoard,我的应用程序需要支持iOS 5(因此我无法使用IB中的嵌入式segues和Containers)
RootViewController代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NewsViewController *news = [[NewsViewController alloc]init];
news.view.frame = self.newsSection.bounds;
[self.newsSection addSubview:news.view];
[self addChildViewController:news];
// Do any additional setup after loading the view.
}
Run Code Online (Sandbox Code Playgroud)
我还将两个UIViewControllers与segue连接起来.UIView newsSection将保持空白.我究竟做错了什么?
编辑:
这对我有用,是正确的方法吗?
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
NewsViewController *news = [storyboard instantiateViewControllerWithIdentifier:@"NewsViewControllerID"];
news.view.frame = self.newsSection.bounds;
[self.newsSection addSubview:news.view];
[self addChildViewController:news];
[news didMoveToParentViewController:self];
}
Run Code Online (Sandbox Code Playgroud) 我有一个UITextField用作密码字段的.它默认secureTextEntry设置为true.我还要UIButton切换密码的显示/隐藏.
当我将文本字段从secureTextEntryset 更改为trueto时false,字体变得怪异.似乎它成为Times New Roman或类似的.
我已经尝试将字体重新设置为大小为14的系统,但它没有改变任何东西.
发生了什么的例子(初始secureTextEntry设置为true):

我的代码:
@IBAction func showHidePwd(sender: AnyObject) {
textfieldPassword.secureTextEntry = !textfieldPassword.secureTextEntry
// Workaround for dot+whitespace problem
if !textfieldPassword.secureTextEntry {
let tempString = textfieldPassword.text
textfieldPassword.text = nil
textfieldPassword.text = tempString
}
textfieldPassword.font = UIFont.systemFontOfSize(14)
if textfieldPassword.secureTextEntry {
showHideButton.setImage(UIImage(named: "EyeClosed"), forState: .Normal)
} else {
showHideButton.setImage(UIImage(named: "EyeOpen"), forState: .Normal)
}
textfieldPassword.becomeFirstResponder()
}
Run Code Online (Sandbox Code Playgroud) 我想知道是否可以翻转UIView同一设备中的内容; 不是指外部显示器,而是设备本身.
我在谷歌搜索了一下,但我能找到的只是外屏.
我与一位同事讨论了"网络标准"在表格中取消的含义.在我们的讨论中,我们以"更改密码"页面为例.我们有一个设计的"发送"按钮和"取消"按钮.两者都是相同的设计.
他声称,在网络标准中,取消按钮不再是按钮,而是将用户转移到另一个页面的链接.在我看来,对于那些页,包括一个取消按钮,它实际上是一个取消按钮,或者重置表单和/或用户发送到预知页面.
谁是对的?链接或按钮......或两者兼而有之?为什么?是否有决定这种标准的链接?
Br,
Paul Peelen
编辑 我想大多数选票的回答都是"正确答案"?
我已经将MKCircle作为MKOverlay添加到我的MKMapView中.我还添加了一个UISlider来决定圆的半径.不幸的是,当使用它时,它似乎有点"滞后",不像我想要的那样流畅.
示例:http: //dl.dropbox.com/u/3077127/mkoverlayDelay.mov
这是我的代码:
- (void)addCircle
{
// draw the radius circle for the marker
double radius = 2000.0;
MKCircle *circle = [MKCircle circleWithCenterCoordinate:location radius:radius];
[circle setTitle:@"background"];
[mapView addOverlay:circle];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:location radius:radius];
[circleLine setTitle:@"line"];
[mapView addOverlay:circleLine];
}
- (void)addCircleWithRadius:(double)radius
{
MKCircle *circle = [MKCircle circleWithCenterCoordinate:location radius:radius];
[circle setTitle:@"background"];
[mapView addOverlay:circle];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:location radius:radius];
[circleLine setTitle:@"line"];
[mapView addOverlay:circleLine];
}
- (void)sliderChanged:(UISlider*)sender
{
[mapView removeOverlays:[mapView overlays]];
double radius = (sender.value * 100);
[self addCircleWithRadius:radius]; …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有一些功能应该基于运行它的设备的语言设置.
我想获得实际语言而不是某些国家/地区设置.例如,如果语言是英语,我不在乎它是美国,英国,澳大利亚等...
我对这个NSLocale对象很熟悉,但它似乎与Region Format设置有关,而不是语言设置(见下面的屏幕截图),所以当我尝试使用它来检索语言时,[locale displayNameForKey:NSLocaleIdentifier value:[locale localeIdentifier]我得到的东西English (United States)不是English; 另外,我认为我需要的是语言数据而不是区域格式(我是对的吗?).
任何人都可以指导我如何检索语言设置?

ios ×9
objective-c ×4
xcode ×2
button ×1
cocoa-touch ×1
core-data ×1
css ×1
dry ×1
html ×1
info-plist ×1
ios4 ×1
iphone ×1
local ×1
locale ×1
localization ×1
mapkit ×1
mfmailcomposeviewcontroller ×1
overlay ×1
setting ×1
swift ×1
uiscrollview ×1
uitextfield ×1
uiview ×1