CLLocationManager在iPhone模拟器上应该假冒库比蒂诺(不是吗?)但它没有,它失败了kCLErrorDomain Code=0.LocationManager的委托接收消息didFailWithError.实现此方法以记录错误,控制台输出以下内容:
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Run Code Online (Sandbox Code Playgroud)
当我遇到这个问题时,我正在研究一个真实的项目,但讨论我的代码是没有意义的,因为我从开发中心下载了"Locations"示例代码(iOS 4更新为2010-06-22)并且问题仍然存在.
当应用程序收到第一个位置更新时,该应用程序将启用"添加"按钮,以便用户可以跟踪其位置,但不执行任何操作.
我添加了一个(普通的)行didFailWithError来记录错误,如果有的话.我得到上述错误.
使用Xcode 3.2.2和目标3.1.3,我可以在运行较旧版本的"Locations"项目时获得固定位置(Cupertino).
有人可以帮忙吗?
谢谢.
我正在尝试将我NSFetchRequest的核心数据设置为检索实体中特定属性的唯一值.即
具有以下信息的实体:
name | rate | factor |
_______|______|________|
John | 3.2 | 4 |
Betty | 5.5 | 7 |
Betty | 2.1 | 2 |
Betty | 3.1 | 2 |
Edward | 4.5 | 5 |
John | 2.3 | 4 |
Run Code Online (Sandbox Code Playgroud)
我如何设置返回数组的请求:John,Betty,Edward?
我有一个NSTableView,委托和数据源指向我的控制器.我试过实施
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
Run Code Online (Sandbox Code Playgroud)
方法,但无论我返回什么,表总是在数据中显示"表视图单元格".我可能做错什么的想法?附上两张照片,显示我已正确设置了委托(它还显示了正确的行数).

请注意,我也尝试过返回@"Hello World"所有内容,但我得到了相同的结果.
如何仅构建和存档或存档iOS应用程序?我想存档到.ipa文件,但无法选择"产品>存档"或"产品>构建>存档构建"菜单(已禁用).我在OS Lion上使用Xcode 4.1.有什么特殊的配置来建立档案选项我不知道?
提前致谢.
我希望我的搜索栏将其背景向上扩展到状态栏下方,如下所示:

这是上图中的相应代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchBar = [[UISearchBar alloc] init];
self.searchBar.delegate = self;
[self.view addSubview:self.searchBar];
self.searchBar.translatesAutoresizingMaskIntoConstraints = NO;
NSDictionary *views = @{@"v":self.searchBar,
@"topLayoutGuide":self.topLayoutGuide};
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLayoutGuide][v]" options:0 metrics:nil views:views]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[v]|" options:0 metrics:nil views:views]];
[self.searchBar setBackgroundImage:[UIImage imageNamed:@"searchbarBG"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];
}
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
Run Code Online (Sandbox Code Playgroud)
当我UISearchDisplayController通过在viewDidLoad方法的末尾附加以下行将搜索栏添加到a时出现问题:
self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
Run Code Online (Sandbox Code Playgroud)
这是我得到的结果:

请注意,图像看起来有所剪裁.这与我在代码中将UIBarPositionTopAttached更改为UIBarPositionTop时的情况不同:

被剪裁的图像让我想到了clipsToBounds,我可以通过在以下结尾添加这段代码来正确显示搜索栏viewDidLoad:
for (UIView *subview in self.searchBar.subviews) {
subview.clipsToBounds = NO;
} …Run Code Online (Sandbox Code Playgroud) 我遇到了这个问题,主屏幕中的应用程序名称显示错误的语言.仅当应用程序不支持用户的首选语言时才会发生这种情况.我已经在Xcode 8和iOS 10中使用模拟器和真实设备中的多个项目对此进行了测试.
如果应用程序不支持用户的首选语言,则使用应用程序的开发区域(CFBundleDevelopmentRegion)显示界面语言,如本文档中所述.到现在为止还挺好.但是,主屏幕中的应用程序名称不符合此标准,它似乎.lproj按字母顺序选择英语或第一个文件夹(如果英语不存在).
假设我的应用支持以下语言:
我的设备设置如下所示:
以下声明:
[NSLocale preferredLanguages]
Run Code Online (Sandbox Code Playgroud)
返回预期结果:
<__NSArrayM 0x79da6b30>(
en
)
Run Code Online (Sandbox Code Playgroud)
而这另一个声明:
[[NSBundle mainBundle] preferredLocalizations]
Run Code Online (Sandbox Code Playgroud)
也返回预期的结果:
<__NSArrayM 0x79716630>(
zh
)
Run Code Online (Sandbox Code Playgroud)
但是,主屏幕中的应用程序名称使用了错误的本地化:
我错过了什么吗?有没有人遇到过这个问题?
重现步骤:
预期成绩:
用户界面和应用程序名称应以应用程序开发语言显示(示例中为中文).
观察结果:
用户界面以应用程序开发语言(示例中为中文)显示,而应用程序名称以日语显示.
我正在尝试使用基于iCloud示例的 NSFetchedResultController将我的CoreData连接到iCloud .
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"date" cacheName:@"Root1"];
aFetchedResultsController.delegate = self;
Run Code Online (Sandbox Code Playgroud)
但是我在第二行得到了这样的警告:警告:语义问题:将'RootViewController*const __strong'传递给不兼容类型'id'的参数.我认为将委托设置为自我应该没问题,但事实并非如此.有人可以帮忙吗?
cocoa-touch delegates objective-c nsfetchedresultscontroller
我已经看到一些示例代码让我想知道在超类中调用指定的初始化程序.说我有一些代码:
@interface NewTableViewCell : UITableViewCell {
}
@end
@implementation NewTableViewCell
- (id) initWithFrame: (CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Do some stuff
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
注意,这initWithFrame是指定的初始化程序UIView,而不是UITableView.这段代码应该始终在调用[UITableViewCell initWithStyle:reuseIdentifier:],还是取决于编码器的意图?
我正在使用Xcode 4.2故事板.我被困在这个连接中.这是正确的吗?我要修改的代码在哪里?实际上我想显示一个新的tableview,具体取决于从上一个tableview传递的变量("row").任何帮助赞赏.
self.newrow =row;// row is the variable passed from previous tableview
NSString *urlString = [NSString stringWithFormat: @"http://ipaddress/iphone.php?id="];
NSString *urlStr=@"";
urlStr=[urlString stringByAppendingString:newrow];
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];
Run Code Online (Sandbox Code Playgroud) 我有一个方法,我需要在另一个方法中调用.在UIViewController中
//This is how i call methoed
tmpUITextView.text= [self ssidValue:1 arrayOf:ssidArray];
//my Method
+ (NSString *)ssidValue:(NSInteger)selectedValue arrayOf:(NSMutableArray *)tmpArray {
NSString *result=[tmpArray objectAtIndex:selectedValue];
NSLog(@"%@",result);
return result;
}
Run Code Online (Sandbox Code Playgroud)
但我正在加油(警告:'UIViewController'可能无法响应'-ssidValue:arrayOf:')并使其崩溃.
请告诉我这里我做错了什么.
提前致谢
ios ×6
objective-c ×4
iphone ×2
xcode ×2
archive ×1
cllocation ×1
cocoa ×1
cocoa-touch ×1
core-data ×1
delegates ×1
ios7 ×1
localization ×1
methods ×1
nsstring ×1
nstableview ×1
simulator ×1
tableview ×1
uisearchbar ×1